diff options
Diffstat (limited to 'cpp')
42 files changed, 930 insertions, 727 deletions
diff --git a/cpp/include/Ice/Buffer.h b/cpp/include/Ice/Buffer.h index d32dd9fe1b7..02e33f3b239 100644 --- a/cpp/include/Ice/Buffer.h +++ b/cpp/include/Ice/Buffer.h @@ -16,7 +16,7 @@ namespace IceInternal { -class ICE_API Buffer : noncopyable +class ICE_API Buffer : public ::Ice::noncopyable { public: diff --git a/cpp/include/Ice/Config.h b/cpp/include/Ice/Config.h index 3b4c9db47a3..5498b0ecd30 100644 --- a/cpp/include/Ice/Config.h +++ b/cpp/include/Ice/Config.h @@ -100,10 +100,9 @@ typedef double Double; #include <JTC/JTC.h> // -// By deriving from this class (private inheritance), other classes -// are made non-copyable +// By deriving from this class, other classes are made non-copyable // -namespace IceInternal +namespace Ice { class noncopyable @@ -111,7 +110,7 @@ class noncopyable protected: noncopyable() { } - ~noncopyable() { } + ~noncopyable() { } // May not be virtual! Classes without virtual operations also derive from noncopyable. private: @@ -122,6 +121,16 @@ private: } // +// Define the Ice and IceInternal namespace, so that we can use the following +// everywhere in our code: +// +// using namespace Ice; +// using namespace IceInternal; +// +namespace Ice { } +namespace IceInternal { } + +// // The Ice version // #define ICE_STRING_VERSION "0.0.1" diff --git a/cpp/include/Ice/Functional.h b/cpp/include/Ice/Functional.h index 07cd9044769..caf8ff06b93 100644 --- a/cpp/include/Ice/Functional.h +++ b/cpp/include/Ice/Functional.h @@ -8,381 +8,502 @@ // // ********************************************************************** -#ifndef ICE_HANDLE_FUNCTIONAL_H -#define ICE_HANDLE_FUNCTIONAL_H +#ifndef ICE_FUNCTIONAL_H +#define ICE_FUNCTIONAL_H #include <Ice/Handle.h> #include <functional> -namespace Ice +namespace IceInternal { -template<class R, class T> -class memFunT - : public std::unary_function<IceInternal::Handle<T>, R> +// ---------------------------------------------------------------------- +// Various function objects that work with handles instead of plain +// pointers. +// ---------------------------------------------------------------------- + +template<class R, class T, class H> +class MemFun : public std::unary_function<H, R> { - typedef R (T::*funT)(void); - funT mfn; + typedef R (T::*MemberFN)(void); + MemberFN _mfn; public: - explicit memFunT(funT p) : mfn(p) { } - R operator()(const IceInternal::Handle<T>& p) const + explicit MemFun(MemberFN p) : _mfn(p) { } + R operator()(H p) const { - return ((p.get() ->* mfn)()); + return (p.get() ->* _mfn)(); } }; -template<class R, class T> -inline memFunT<R, T> -memFun(R (T::*p)(void)) +template<class R, class T, class H, class A> +class MemFun1 : public std::binary_function<H, A, R> { - return (memFunT<R, T>(p)); -} - -template<class R, class T, class A> -class memFun1T - : public std::binary_function<IceInternal::Handle<T>, A, R> -{ - typedef R (T::*funT)(A); - funT mfn; + typedef R (T::*MemberFN)(A); + MemberFN _mfn; public: - explicit memFun1T(funT p) : mfn(p) { } - R operator()(const IceInternal::Handle<T>& h, A arg) const + explicit MemFun1(MemberFN p) : _mfn(p) { } + R operator()(H h, A arg) const { - return ((p.get() ->* mfn)(arg)); + return (p.get() ->* _mfn)(arg); } }; -template<class R, class T, class A> -inline memFun1T<R, T, A> -memFun1(R (T::*p)(A)) +template<class T, class H> +class VoidMemFun : public std::unary_function<H, void> { - return (memFun1T<R, T, A>(p)); -} + typedef void (T::*MemberFN)(void); + MemberFN _mfn; -template<class T> -class voidMemFunT - : public std::unary_function<IceInternal::Handle<T>, void> +public: + + explicit VoidMemFun(MemberFN p) : _mfn(p) { } + void operator()(H p) const + { + (p.get() ->* _mfn)(); + } +}; + +template<class T, class H, class A> +class VoidMemFun1 : public std::binary_function<H, A, void> { - typedef void (T::*funT)(void); - funT mfn; + typedef void (T::*MemberFN)(A); + MemberFN _mfn; public: - explicit voidMemFunT(funT p) : mfn(p) { } - void operator()(const IceInternal::Handle<T>& p) const + explicit VoidMemFun1(MemberFN p) : _mfn(p) { } + void operator()(H h, A arg) const { - (p.get() ->* mfn)(); + (p.get() ->* _mfn)(arg); } }; -template<class T> -inline voidMemFunT<T> -voidMemFun(void (T::*p)(void)) +template<class R, class K, class T, class H> +class SecondMemFun : public std::unary_function<std::pair<K, H>, R> { - return voidMemFunT<T>(p); -} + typedef R (T::*MemberFN)(void); + MemberFN _mfn; -template<class T, class A> -class voidMemFun1T - : public std::binary_function<IceInternal::Handle<T>, A, void> +public: + + explicit SecondMemFun(MemberFN p) : _mfn(p) { } + R operator()(std::pair<K, H> p) const + { + return (p.second.get() ->* _mfn)(); + } +}; + +template<class R, class K, class T, class H, class A> +class SecondMemFun1 : public std::binary_function<std::pair<K, H>, A, R> { - typedef void (T::*funT)(A); - funT mfn; + typedef R (T::*MemberFN)(A); + MemberFN _mfn; public: - explicit voidMemFun1T(funT p) : mfn(p) { } - void operator()(const IceInternal::Handle<T>& h, A arg) const + explicit SecondMemFun1(MemberFN p) : _mfn(p) { } + R operator()(std::pair<K, H> h, A arg) const { - (p.get() ->* mfn)(arg); + return (p.second.get() ->* _mfn)(arg); } }; -template<class T, class A> -inline voidMemFun1T<T, A> -voidMemFun1(void (T::*p)(A)) +template<class K, class T, class H> +class SecondVoidMemFun : public std::unary_function<std::pair<K, H>, void> { - return voidMemFun1T<T, A>(p); -} + typedef void (T::*MemberFN)(void); + MemberFN _mfn; -template<class R, class K, class T> -class secondMemFunT - : public std::unary_function<std::pair<K, IceInternal::Handle<T> >, R> +public: + + explicit SecondVoidMemFun(MemberFN p) : _mfn(p) { } + void operator()(std::pair<K, H> p) const + { + (p.second.get() ->* _mfn)(); + } +}; + +template<class K, class T, class H, class A> +class SecondVoidMemFun1 : public std::binary_function<std::pair<K, H>, A, void> { - typedef R (T::*funT)(void); - funT mfn; + typedef void (T::*MemberFN)(A); + MemberFN _mfn; public: - explicit secondMemFunT(funT p) : mfn(p) { } - R operator()(std::pair<K, const IceInternal::Handle<T>&> p) const + explicit SecondVoidMemFun1(MemberFN p) : _mfn(p) { } + void operator()(std::pair<K, H> h, A arg) const { - return ((p.second.get() ->* mfn)()); + (p.second.get() ->* _mfn)(arg); } }; -template<class R, class K, class T> -inline secondMemFunT<R, K, T> -secondMemFun(R (T::*p)(void)) +template<class R, class T, class H> +class ConstMemFun : public std::unary_function<H, R> { - return (secondMemFunT<R, K, T>(p)); -} + typedef R (T::*MemberFN)(void) const; + MemberFN _mfn; -template<class R, class K, class T, class A> -class secondMemFun1T - : public std::binary_function<std::pair<K, const IceInternal::Handle<T>&>, A, R> +public: + + explicit ConstMemFun(MemberFN p) : _mfn(p) { } + R operator()(H p) const + { + return (p.get() ->* _mfn)(); + } +}; + +template<class R, class T, class H, class A> +class ConstMemFun1 : public std::binary_function<H, A, R> { - typedef R (T::*funT)(A); - funT mfn; + typedef R (T::*MemberFN)(A); + MemberFN _mfn; public: - explicit secondMemFun1T(funT p) : mfn(p) { } - R operator()(std::pair<K, const IceInternal::Handle<T>&> h, A arg) const + explicit ConstMemFun1(MemberFN p) : _mfn(p) { } + R operator()(H h, A arg) const { - return ((p.second.get() ->* mfn)(arg)); + return (p.get() ->* _mfn)(arg); } }; -template<class R, class K, class T, class A> -inline secondMemFun1T<R, K, T, A> -secondMemFun1(R (T::*p)(A)) +template<class T, class H> +class ConstVoidMemFun : public std::unary_function<H, void> { - return (secondMemFun1T<R, K, T, A>(p)); -} + typedef void (T::*MemberFN)(void) const; + MemberFN _mfn; -template<class K, class T> -class secondVoidMemFunT - : public std::unary_function<std::pair<K, IceInternal::Handle<T> >, void> +public: + + explicit ConstVoidMemFun(MemberFN p) : _mfn(p) { } + void operator()(H p) const + { + (p.get() ->* _mfn)(); + } +}; + +template<class T, class H, class A> +class ConstVoidMemFun1 : public std::binary_function<H, A, void> { - typedef void (T::*funT)(void); - funT mfn; + typedef void (T::*MemberFN)(A); + MemberFN _mfn; public: - explicit secondVoidMemFunT(funT p) : mfn(p) { } - void operator()(std::pair<K, IceInternal::Handle<T> > p) const + explicit ConstVoidMemFun1(MemberFN p) : _mfn(p) { } + void operator()(H h, A arg) const { - (p.second.get() ->* mfn)(); + (p.get() ->* _mfn)(arg); } }; -template<class K, class T> -inline secondVoidMemFunT<K, T> -secondVoidMemFun(void (T::*p)(void)) +template<class R, class K, class T, class H> +class SecondConstMemFun : public std::unary_function<std::pair<K, H>, R> { - return secondVoidMemFunT<K, T>(p); -} + typedef R (T::*MemberFN)(void) const; + MemberFN _mfn; -template<class K, class T, class A> -class secondVoidMemFun1T - : public std::binary_function<std::pair<K, IceInternal::Handle<T> >, A, void> +public: + + explicit SecondConstMemFun(MemberFN p) : _mfn(p) { } + R operator()(std::pair<K, H> p) const + { + return (p.second.get() ->* _mfn)(); + } +}; + +template<class R, class K, class T, class H, class A> +class SecondConstMemFun1 : public std::binary_function<std::pair<K, H>, A, R> { - typedef void (T::*funT)(A); - funT mfn; + typedef R (T::*MemberFN)(A); + MemberFN _mfn; public: - explicit secondVoidMemFun1T(funT p) : mfn(p) { } - void operator()(std::pair<K, IceInternal::Handle<T> > h, A arg) const + explicit SecondConstMemFun1(MemberFN p) : _mfn(p) { } + R operator()(std::pair<K, H> h, A arg) const { - (p.second.get() ->* mfn)(arg); + return (p.second.get() ->* _mfn)(arg); } }; -template<class K, class T, class A> -inline secondVoidMemFun1T<K, T, A> -secondVoidMemFun1(void (T::*p)(A)) +template<class K, class T, class H> +class SecondConstVoidMemFun : public std::unary_function<std::pair<K, H>, void> { - return secondVoidMemFun1T<K, T, A>(p); -} + typedef void (T::*MemberFN)(void) const; + MemberFN _mfn; -template<class R, class T> -class constMemFunT - : public std::unary_function<IceInternal::Handle<T>, R> +public: + + explicit SecondConstVoidMemFun(MemberFN p) : _mfn(p) { } + void operator()(std::pair<K, H> p) const + { + (p.second.get() ->* _mfn)(); + } +}; + +template<class K, class T, class H, class A> +class SecondConstVoidMemFun1 : public std::binary_function<std::pair<K, H>, A, void> { - typedef R (T::*funT)(void) const; - funT mfn; + typedef void (T::*MemberFN)(A); + MemberFN _mfn; public: - explicit constMemFunT(funT p) : mfn(p) { } - R operator()(const IceInternal::Handle<T>& p) const + explicit SecondConstVoidMemFun1(MemberFN p) : _mfn(p) { } + void operator()(std::pair<K, H> h, A arg) const { - return ((p.get() ->* mfn)()); + (p.second.get() ->* _mfn)(arg); } }; +} + +// ---------------------------------------------------------------------- +// Inline functions that return function objects that work with +// IceInternal::Handle +// ---------------------------------------------------------------------- + +namespace IceInternal +{ + template<class R, class T> -inline constMemFunT<R, T> -constMemFun(R (T::*p)(void) const) +inline ::IceInternal::MemFun<R, T, Handle<T> > +memFun(R (T::*p)(void)) { - return (constMemFunT<R, T>(p)); + return ::IceInternal::MemFun<R, T, Handle<T> >(p); } template<class R, class T, class A> -class constMemFun1T - : public std::binary_function<IceInternal::Handle<T>, A, R> +inline ::IceInternal::MemFun1<R, T, Handle<T>, A> +memFun1(R (T::*p)(A)) { - typedef R (T::*funT)(A); - funT mfn; + return ::IceInternal::MemFun1<R, T, Handle<T>, A>(p); +} -public: +template<class T> +inline ::IceInternal::VoidMemFun<T, Handle<T> > +voidMemFun(void (T::*p)(void)) +{ + return ::IceInternal::VoidMemFun<T, Handle<T> >(p); +} - explicit constMemFun1T(funT p) : mfn(p) { } - R operator()(const IceInternal::Handle<T>& h, A arg) const - { - return ((p.get() ->* mfn)(arg)); - } -}; +template<class T, class A> +inline ::IceInternal::VoidMemFun1<T, Handle<T>, A> +voidMemFun1(void (T::*p)(A)) +{ + return ::IceInternal::VoidMemFun1<T, Handle<T>, A>(p); +} -template<class R, class T, class A> -inline constMemFun1T<R, T, A> -constMemFun1(R (T::*p)(A)) +template<class R, class K, class T> +inline ::IceInternal::SecondMemFun<R, K, T, Handle<T> > +secondMemFun(R (T::*p)(void)) { - return (constMemFun1T<R, T, A>(p)); + return ::IceInternal::SecondMemFun<R, K, T, Handle<T> >(p); } -template<class T> -class constVoidMemFunT - : public std::unary_function<IceInternal::Handle<T>, void> +template<class R, class K, class T, class A> +inline ::IceInternal::SecondMemFun1<R, K, T, Handle<T>, A> +secondMemFun1(R (T::*p)(A)) { - typedef void (T::*funT)(void) const; - funT mfn; + return ::IceInternal::SecondMemFun1<R, K, T, Handle<T>, A>(p); +} -public: +template<class K, class T> +inline ::IceInternal::SecondVoidMemFun<K, T, Handle<T> > +secondVoidMemFun(void (T::*p)(void)) +{ + return ::IceInternal::SecondVoidMemFun<K, T, Handle<T> >(p); +} - explicit constVoidMemFunT(funT p) : mfn(p) { } - void operator()(const IceInternal::Handle<T>& p) const - { - (p.get() ->* mfn)(); - } -}; +template<class K, class T, class A> +inline ::IceInternal::SecondVoidMemFun1<K, T, Handle<T>, A> +secondVoidMemFun1(void (T::*p)(A)) +{ + return ::IceInternal::SecondVoidMemFun1<K, T, Handle<T>, A>(p); +} + +template<class R, class T> +inline ::IceInternal::ConstMemFun<R, T, Handle<T> > +constMemFun(R (T::*p)(void) const) +{ + return ::IceInternal::ConstMemFun<R, T, Handle<T> >(p); +} + +template<class R, class T, class A> +inline ::IceInternal::ConstMemFun1<R, T, Handle<T>, A> +constMemFun1(R (T::*p)(A)) +{ + return ::IceInternal::ConstMemFun1<R, T, Handle<T>, A>(p); +} template<class T> -inline constVoidMemFunT<T> +inline ::IceInternal::ConstVoidMemFun<T, Handle<T> > constVoidMemFun(void (T::*p)(void) const) { - return constVoidMemFunT<T>(p); + return ::IceInternal::ConstVoidMemFun<T, Handle<T> >(p); } template<class T, class A> -class constVoidMemFun1T - : public std::binary_function<IceInternal::Handle<T>, A, void> +inline ::IceInternal::ConstVoidMemFun1<T, Handle<T>, A> +constVoidMemFun1(void (T::*p)(A)) { - typedef void (T::*funT)(A); - funT mfn; + return ::IceInternal::ConstVoidMemFun1<T, Handle<T>, A>(p); +} -public: +template<class R, class K, class T> +inline ::IceInternal::SecondConstMemFun<R, K, T, Handle<T> > +secondConstMemFun(R (T::*p)(void) const) +{ + return ::IceInternal::SecondConstMemFun<R, K, T, Handle<T> >(p); +} - explicit constVoidMemFun1T(funT p) : mfn(p) { } - void operator()(const IceInternal::Handle<T>& h, A arg) const - { - (p.get() ->* mfn)(arg); - } -}; +template<class R, class K, class T, class A> +inline ::IceInternal::SecondConstMemFun1<R, K, T, Handle<T>, A> +secondConstMemFun1(R (T::*p)(A)) +{ + return ::IceInternal::SecondConstMemFun1<R, K, T, Handle<T>, A>(p); +} -template<class T, class A> -inline constVoidMemFun1T<T, A> -constVoidMemFun1(void (T::*p)(A)) +template<class K, class T> +inline ::IceInternal::SecondConstVoidMemFun<K, T, Handle<T> > +secondConstVoidMemFun(void (T::*p)(void) const) { - return constVoidMemFun1T<T, A>(p); + return ::IceInternal::SecondConstVoidMemFun<K, T, Handle<T> >(p); } -template<class R, class K, class T> -class secondConstMemFunT - : public std::unary_function<std::pair<K, IceInternal::Handle<T> >, R> +template<class K, class T, class A> +inline ::IceInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A> +secondConstVoidMemFun1(void (T::*p)(A)) { - typedef R (T::*funT)(void) const; - funT mfn; + return ::IceInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A>(p); +} -public: +} - explicit secondConstMemFunT(funT p) : mfn(p) { } - R operator()(std::pair<K, const IceInternal::Handle<T>&> p) const - { - return ((p.second.get() ->* mfn)()); - } -}; +// ---------------------------------------------------------------------- +// Inline functions that return function objects that work with +// Ice::Handle +// ---------------------------------------------------------------------- -template<class R, class K, class T> -inline secondConstMemFunT<R, K, T> -secondConstMemFun(R (T::*p)(void) const) +namespace Ice { - return (secondConstMemFunT<R, K, T>(p)); + +template<class R, class T> +inline ::IceInternal::MemFun<R, T, Handle<T> > +memFun(R (T::*p)(void)) +{ + return ::IceInternal::MemFun<R, T, Handle<T> >(p); } -template<class R, class K, class T, class A> -class secondConstMemFun1T - : public std::binary_function<std::pair<K, const IceInternal::Handle<T>&>, A, R> +template<class R, class T, class A> +inline ::IceInternal::MemFun1<R, T, Handle<T>, A> +memFun1(R (T::*p)(A)) { - typedef R (T::*funT)(A); - funT mfn; + return ::IceInternal::MemFun1<R, T, Handle<T>, A>(p); +} -public: +template<class T> +inline ::IceInternal::VoidMemFun<T, Handle<T> > +voidMemFun(void (T::*p)(void)) +{ + return ::IceInternal::VoidMemFun<T, Handle<T> >(p); +} - explicit secondConstMemFun1T(funT p) : mfn(p) { } - R operator()(std::pair<K, const IceInternal::Handle<T>&> h, A arg) const - { - return ((p.second.get() ->* mfn)(arg)); - } -}; +template<class T, class A> +inline ::IceInternal::VoidMemFun1<T, Handle<T>, A> +voidMemFun1(void (T::*p)(A)) +{ + return ::IceInternal::VoidMemFun1<T, Handle<T>, A>(p); +} + +template<class R, class K, class T> +inline ::IceInternal::SecondMemFun<R, K, T, Handle<T> > +secondMemFun(R (T::*p)(void)) +{ + return ::IceInternal::SecondMemFun<R, K, T, Handle<T> >(p); +} template<class R, class K, class T, class A> -inline secondConstMemFun1T<R, K, T, A> -secondConstMemFun1(R (T::*p)(A)) +inline ::IceInternal::SecondMemFun1<R, K, T, Handle<T>, A> +secondMemFun1(R (T::*p)(A)) { - return (secondConstMemFun1T<R, K, T, A>(p)); + return ::IceInternal::SecondMemFun1<R, K, T, Handle<T>, A>(p); } template<class K, class T> -class secondConstVoidMemFunT - : public std::unary_function<std::pair<K, IceInternal::Handle<T> >, void> +inline ::IceInternal::SecondVoidMemFun<K, T, Handle<T> > +secondVoidMemFun(void (T::*p)(void)) { - typedef void (T::*funT)(void) const; - funT mfn; + return ::IceInternal::SecondVoidMemFun<K, T, Handle<T> >(p); +} -public: +template<class K, class T, class A> +inline ::IceInternal::SecondVoidMemFun1<K, T, Handle<T>, A> +secondVoidMemFun1(void (T::*p)(A)) +{ + return ::IceInternal::SecondVoidMemFun1<K, T, Handle<T>, A>(p); +} - explicit secondConstVoidMemFunT(funT p) : mfn(p) { } - void operator()(std::pair<K, IceInternal::Handle<T> > p) const - { - (p.second.get() ->* mfn)(); - } -}; +template<class R, class T> +inline ::IceInternal::ConstMemFun<R, T, Handle<T> > +constMemFun(R (T::*p)(void) const) +{ + return ::IceInternal::ConstMemFun<R, T, Handle<T> >(p); +} -template<class K, class T> -inline secondConstVoidMemFunT<K, T> -secondConstVoidMemFun(void (T::*p)(void) const) +template<class R, class T, class A> +inline ::IceInternal::ConstMemFun1<R, T, Handle<T>, A> +constMemFun1(R (T::*p)(A)) { - return secondConstVoidMemFunT<K, T>(p); + return ::IceInternal::ConstMemFun1<R, T, Handle<T>, A>(p); } -template<class K, class T, class A> -class secondConstVoidMemFun1T - : public std::binary_function<std::pair<K, IceInternal::Handle<T> >, A, void> +template<class T> +inline ::IceInternal::ConstVoidMemFun<T, Handle<T> > +constVoidMemFun(void (T::*p)(void) const) { - typedef void (T::*funT)(A); - funT mfn; + return ::IceInternal::ConstVoidMemFun<T, Handle<T> >(p); +} -public: +template<class T, class A> +inline ::IceInternal::ConstVoidMemFun1<T, Handle<T>, A> +constVoidMemFun1(void (T::*p)(A)) +{ + return ::IceInternal::ConstVoidMemFun1<T, Handle<T>, A>(p); +} - explicit secondConstVoidMemFun1T(funT p) : mfn(p) { } - void operator()(std::pair<K, IceInternal::Handle<T> > h, A arg) const - { - (p.second.get() ->* mfn)(arg); - } -}; +template<class R, class K, class T> +inline ::IceInternal::SecondConstMemFun<R, K, T, Handle<T> > +secondConstMemFun(R (T::*p)(void) const) +{ + return ::IceInternal::SecondConstMemFun<R, K, T, Handle<T> >(p); +} + +template<class R, class K, class T, class A> +inline ::IceInternal::SecondConstMemFun1<R, K, T, Handle<T>, A> +secondConstMemFun1(R (T::*p)(A)) +{ + return ::IceInternal::SecondConstMemFun1<R, K, T, Handle<T>, A>(p); +} + +template<class K, class T> +inline ::IceInternal::SecondConstVoidMemFun<K, T, Handle<T> > +secondConstVoidMemFun(void (T::*p)(void) const) +{ + return ::IceInternal::SecondConstVoidMemFun<K, T, Handle<T> >(p); +} template<class K, class T, class A> -inline secondConstVoidMemFun1T<K, T, A> +inline ::IceInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A> secondConstVoidMemFun1(void (T::*p)(A)) { - return secondConstVoidMemFun1T<K, T, A>(p); + return ::IceInternal::SecondConstVoidMemFun1<K, T, Handle<T>, A>(p); } } diff --git a/cpp/include/Ice/Handle.h b/cpp/include/Ice/Handle.h index 9b25af07868..d82a73848c6 100644 --- a/cpp/include/Ice/Handle.h +++ b/cpp/include/Ice/Handle.h @@ -14,9 +14,12 @@ #include <Ice/Config.h> #include <algorithm> -namespace IceInternal -{ - +// +// "Handle" or "smart pointer" classes for classes derived from +// Ice::Shared or Ice::SimpleShared. +// +// IceInternal::Handle +// =================== // // Generic handle class, using intrusive reference counting. Two // global operations IceInternal::incRef(T*) and @@ -25,18 +28,32 @@ namespace IceInternal // be used for types which are declared but not defined, provided that // the two above mentioned operations are declared as well. // +// Ice::Handle +// =========== +// +// A simplified handle class similar to IceInternal::Handle, but +// intended to be used by application code, and therfore in the Ice +// namespace instead of in IceInternal. No global operations +// incRef(T*) and decRef(T*) must be declared for this handle +// class. Instead, this handle class call __incRef() and __decRef() on +// T directly. +// + +namespace IceInternal +{ + template<typename T> class Handle { public: - typedef T element_type; - Handle(T* p = 0) : _ptr(p) { if (_ptr) + { incRef(_ptr); + } } template<typename Y> @@ -44,7 +61,9 @@ public: _ptr(r._ptr) { if (_ptr) + { incRef(_ptr); + } } #ifdef WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here??? @@ -56,13 +75,17 @@ public: _ptr(r._ptr) { if (_ptr) + { incRef(_ptr); + } } ~Handle() { if (_ptr) + { decRef(_ptr); + } } Handle& operator=(T* p) @@ -70,10 +93,14 @@ public: if (_ptr != p) { if (p) + { incRef(p); + } if (_ptr) + { decRef(_ptr); + } _ptr = p; } @@ -86,10 +113,14 @@ public: if (_ptr != r._ptr) { if (r._ptr) + { incRef(r._ptr); + } if (_ptr) + { decRef(_ptr); + } _ptr = r._ptr; } @@ -106,10 +137,14 @@ public: if (_ptr != r._ptr) { if (r._ptr) + { incRef(r._ptr); + } if (_ptr) + { decRef(_ptr); + } _ptr = r._ptr; } @@ -128,6 +163,8 @@ public: return Handle(dynamic_cast<T*>(p)); } + typedef T element_type; + T* get() const { return _ptr; } T* operator->() const { return _ptr; } operator bool() const { return _ptr ? true : false; } @@ -163,6 +200,205 @@ inline bool operator<(const Handle<T>& a, const Handle<U>& b) return *a.get() < *b.get(); } +template<typename T, typename U> +inline bool operator<=(const Handle<T>& a, const Handle<U>& b) +{ + return *a.get() <= *b.get(); +} + +template<typename T, typename U> +inline bool operator>(const Handle<T>& a, const Handle<U>& b) +{ + return *a.get() > *b.get(); +} + +template<typename T, typename U> +inline bool operator>=(const Handle<T>& a, const Handle<U>& b) +{ + return *a.get() >= *b.get(); +} + +} + +namespace Ice +{ + +template<typename T> +class Handle +{ +public: + + Handle(T* p = 0) : + _ptr(p) + { + if (_ptr) + { + _ptr->__incRef(); + } + } + + template<typename Y> + Handle(const Handle<Y>& r) : + _ptr(r._ptr) + { + if (_ptr) + { + _ptr->__incRef(); + } + } + +#ifdef WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here??? + template<> + Handle(const Handle<T>& r) : +#else + Handle(const Handle& r) : +#endif + _ptr(r._ptr) + { + if (_ptr) + { + _ptr->__incRef(); + } + } + + ~Handle() + { + if (_ptr) + { + _ptr->__decRef(); + } + } + + Handle& operator=(T* p) + { + if (_ptr != p) + { + if (p) + { + p->__incRef(); + } + + if (_ptr) + { + _ptr->__decRef(); + } + + _ptr = p; + } + return *this; + } + + template<typename Y> + Handle& operator=(const Handle<Y>& r) + { + if (_ptr != r._ptr) + { + if (r._ptr) + { + r._ptr->__incRef(); + } + + if (_ptr) + { + _ptr->__decRef(); + } + + _ptr = r._ptr; + } + return *this; + } + +#ifdef WIN32 // COMPILERBUG: Is VC++ or GNU C++ right here??? + template<> + Handle& operator=(const Handle<T>& r) +#else + Handle& operator=(const Handle& r) +#endif + { + if (_ptr != r._ptr) + { + if (r._ptr) + { + r._ptr->__incRef(); + } + + if (_ptr) + { + _ptr->__decRef(); + } + + _ptr = r._ptr; + } + return *this; + } + + template<class Y> + static Handle dynamicCast(const Handle<Y>& r) + { + return Handle(dynamic_cast<T*>(r._ptr)); + } + + template<class Y> + static Handle dynamicCast(Y* p) + { + return Handle(dynamic_cast<T*>(p)); + } + + typedef T element_type; + + T* get() const { return _ptr; } + T* operator->() const { return _ptr; } + operator bool() const { return _ptr ? true : false; } + + void swap(Handle& other) { std::swap(_ptr, other._ptr); } + +#ifndef WIN32 // COMPILERBUG: VC++ 6.0 doesn't understand this + + template<typename Y> friend class Handle; + +protected: + +#endif + + T* _ptr; +}; + +template<typename T, typename U> +inline bool operator==(const Handle<T>& a, const Handle<U>& b) +{ + return *a.get() == *b.get(); +} + +template<typename T, typename U> +inline bool operator!=(const Handle<T>& a, const Handle<U>& b) +{ + return *a.get() != *b.get(); +} + +template<typename T, typename U> +inline bool operator<(const Handle<T>& a, const Handle<U>& b) +{ + return *a.get() < *b.get(); +} + +template<typename T, typename U> +inline bool operator<=(const Handle<T>& a, const Handle<U>& b) +{ + return *a.get() <= *b.get(); +} + +template<typename T, typename U> +inline bool operator>(const Handle<T>& a, const Handle<U>& b) +{ + return *a.get() > *b.get(); +} + +template<typename T, typename U> +inline bool operator>=(const Handle<T>& a, const Handle<U>& b) +{ + return *a.get() >= *b.get(); +} + } #endif diff --git a/cpp/include/Ice/Incoming.h b/cpp/include/Ice/Incoming.h index c8b0fbce5e0..72312ba094b 100644 --- a/cpp/include/Ice/Incoming.h +++ b/cpp/include/Ice/Incoming.h @@ -18,7 +18,7 @@ namespace IceInternal { -class ICE_API Incoming : noncopyable +class ICE_API Incoming : public ::Ice::noncopyable { public: diff --git a/cpp/include/Ice/LocalObject.h b/cpp/include/Ice/LocalObject.h index 64f4bf899e1..b7d1779a2c0 100644 --- a/cpp/include/Ice/LocalObject.h +++ b/cpp/include/Ice/LocalObject.h @@ -41,7 +41,7 @@ protected: LocalObjectPtr _ptr; }; -class ICE_API LocalObject : public ::IceInternal::Shared +class ICE_API LocalObject : public ::Ice::Shared { public: diff --git a/cpp/include/Ice/Outgoing.h b/cpp/include/Ice/Outgoing.h index e1dbc330428..33c7ffdfd28 100644 --- a/cpp/include/Ice/Outgoing.h +++ b/cpp/include/Ice/Outgoing.h @@ -46,7 +46,7 @@ private: std::auto_ptr< ::Ice::LocalException> _ex; }; -class ICE_API Outgoing : noncopyable, public JTCMonitorT< JTCMutex > +class ICE_API Outgoing : public ::Ice::noncopyable, public JTCMonitorT< JTCMutex > { public: diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index 21b7bdfa72d..697f2f15a45 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -44,7 +44,7 @@ protected: namespace IceProxy { namespace Ice { -class ICE_API Object : public ::IceInternal::Shared, JTCMutex +class ICE_API Object : public ::Ice::Shared, JTCMutex { public: @@ -97,7 +97,7 @@ private: namespace IceDelegate { namespace Ice { -class ICE_API Object : public ::IceInternal::Shared +class ICE_API Object : public ::Ice::Shared { public: diff --git a/cpp/include/Ice/Shared.h b/cpp/include/Ice/Shared.h index 51430f7ea01..1658200a9f3 100644 --- a/cpp/include/Ice/Shared.h +++ b/cpp/include/Ice/Shared.h @@ -13,19 +13,42 @@ #include <Ice/Config.h> -namespace IceInternal -{ - // -// Simple, non thread-safe intrusive base class for reference-counted -// types. +// Base classes for reference counted types. Note that the Ice +// namespace is used instead of IceInternal, so that user code can use +// these base classes as well. +// +// For "smart pointers" or "handles" for reference counted types +// derived from these base classes, use IceInternal::Handle (only for +// Ice internal stuff, of course), or Ice::Handle (for application +// code). +// +// Ice::SimpleShared +// ================= +// +// A non thread-safe base class for reference-counted types. // -class ICE_API SimpleShared : noncopyable +// Ice::Shared +// =========== +// +// A thread-safe base class for reference-counted types. +// +namespace Ice +{ + +class SimpleShared : public noncopyable { public: - SimpleShared(); - virtual ~SimpleShared(); + SimpleShared() : + _ref(0), + _noDelete(false) + { + } + + virtual ~SimpleShared() + { + } void __incRef() { @@ -61,15 +84,19 @@ private: bool _noDelete; }; -// -// Thread-safe intrusive base class for reference-counted types. -// -class ICE_API Shared : noncopyable +class Shared : public noncopyable { public: - Shared(); - virtual ~Shared(); + Shared() : + _ref(0), + _noDelete(false) + { + } + + virtual ~Shared() + { + } void __incRef() { diff --git a/cpp/include/Slice/OutputUtil.h b/cpp/include/Slice/OutputUtil.h index 734d35ebb67..c6e1fa1e584 100644 --- a/cpp/include/Slice/OutputUtil.h +++ b/cpp/include/Slice/OutputUtil.h @@ -11,28 +11,39 @@ #ifndef SLICE_OUTPUT_UTIL_H #define SLICE_OUTPUT_UTIL_H +#include <Ice/Config.h> #include <fstream> #include <sstream> #include <stack> +#ifdef WIN32 +# ifdef SLICE_API_EXPORTS +# define SLICE_API __declspec(dllexport) +# else +# define SLICE_API __declspec(dllimport) +# endif +#else +# define SLICE_API /**/ +#endif + namespace Slice { -class ICE_API NextLine { }; -class ICE_API StartBlock { }; -class ICE_API EndBlock { }; -class ICE_API Separator { }; +class SLICE_API NextLine { }; +class SLICE_API StartBlock { }; +class SLICE_API EndBlock { }; +class SLICE_API Separator { }; -extern ICE_API NextLine nl; -extern ICE_API StartBlock sb; -extern ICE_API EndBlock eb; -extern ICE_API Separator sp; +extern SLICE_API NextLine nl; +extern SLICE_API StartBlock sb; +extern SLICE_API EndBlock eb; +extern SLICE_API Separator sp; // ---------------------------------------------------------------------- // Indent // ---------------------------------------------------------------------- -class ICE_API Output : ::IceInternal::noncopyable +class SLICE_API Output : public ::Ice::noncopyable { public: @@ -94,10 +105,10 @@ Output& operator<<(Output& out, std::ios_base& (*val)(std::ios_base&)) return out; } -ICE_API Output& operator<<(Output&, const NextLine&); -ICE_API Output& operator<<(Output&, const StartBlock&); -ICE_API Output& operator<<(Output&, const EndBlock&); -ICE_API Output& operator<<(Output&, const Separator&); +SLICE_API Output& operator<<(Output&, const NextLine&); +SLICE_API Output& operator<<(Output&, const StartBlock&); +SLICE_API Output& operator<<(Output&, const EndBlock&); +SLICE_API Output& operator<<(Output&, const Separator&); } diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h index 433a32c4ff2..48c41ad84fa 100644 --- a/cpp/include/Slice/Parser.h +++ b/cpp/include/Slice/Parser.h @@ -17,6 +17,16 @@ #include <stack> #include <map> +#ifdef WIN32 +# ifdef SLICE_API_EXPORTS +# define SLICE_API __declspec(dllexport) +# else +# define SLICE_API __declspec(dllimport) +# endif +#else +# define SLICE_API /**/ +#endif + namespace Slice { @@ -41,77 +51,26 @@ class Enumerator; class Native; class Unit; -} - -namespace IceInternal -{ - -void ICE_API incRef(::Slice::GrammerBase*); -void ICE_API decRef(::Slice::GrammerBase*); -void ICE_API incRef(::Slice::SyntaxTreeBase*); -void ICE_API decRef(::Slice::SyntaxTreeBase*); -void ICE_API incRef(::Slice::Type*); -void ICE_API decRef(::Slice::Type*); -void ICE_API incRef(::Slice::Builtin*); -void ICE_API decRef(::Slice::Builtin*); -void ICE_API incRef(::Slice::Contained*); -void ICE_API decRef(::Slice::Contained*); -void ICE_API incRef(::Slice::Container*); -void ICE_API decRef(::Slice::Container*); -void ICE_API incRef(::Slice::Module*); -void ICE_API decRef(::Slice::Module*); -void ICE_API incRef(::Slice::Constructed*); -void ICE_API decRef(::Slice::Constructed*); -void ICE_API incRef(::Slice::ClassDecl*); -void ICE_API decRef(::Slice::ClassDecl*); -void ICE_API incRef(::Slice::ClassDef*); -void ICE_API decRef(::Slice::ClassDef*); -void ICE_API incRef(::Slice::Proxy*); -void ICE_API decRef(::Slice::Proxy*); -void ICE_API incRef(::Slice::Struct*); -void ICE_API decRef(::Slice::Struct*); -void ICE_API incRef(::Slice::Operation*); -void ICE_API decRef(::Slice::Operation*); -void ICE_API incRef(::Slice::DataMember*); -void ICE_API decRef(::Slice::DataMember*); -void ICE_API incRef(::Slice::Sequence*); -void ICE_API decRef(::Slice::Sequence*); -void ICE_API incRef(::Slice::Dictionary*); -void ICE_API decRef(::Slice::Dictionary*); -void ICE_API incRef(::Slice::Enum*); -void ICE_API decRef(::Slice::Enum*); -void ICE_API incRef(::Slice::Enumerator*); -void ICE_API decRef(::Slice::Enumerator*); -void ICE_API incRef(::Slice::Native*); -void ICE_API decRef(::Slice::Native*); -void ICE_API incRef(::Slice::Unit*); -void ICE_API decRef(::Slice::Unit*); - -} - -namespace Slice -{ - -typedef ::IceInternal::Handle<GrammerBase> GrammerBasePtr; -typedef ::IceInternal::Handle<SyntaxTreeBase> SyntaxTreeBasePtr; -typedef ::IceInternal::Handle<Type> TypePtr; -typedef ::IceInternal::Handle<Builtin> BuiltinPtr; -typedef ::IceInternal::Handle<Contained> ContainedPtr; -typedef ::IceInternal::Handle<Container> ContainerPtr; -typedef ::IceInternal::Handle<Module> ModulePtr; -typedef ::IceInternal::Handle<Constructed> ConstructedPtr; -typedef ::IceInternal::Handle<ClassDecl> ClassDeclPtr; -typedef ::IceInternal::Handle<ClassDef> ClassDefPtr; -typedef ::IceInternal::Handle<Proxy> ProxyPtr; -typedef ::IceInternal::Handle<Struct> StructPtr; -typedef ::IceInternal::Handle<Operation> OperationPtr; -typedef ::IceInternal::Handle<DataMember> DataMemberPtr; -typedef ::IceInternal::Handle<Sequence> SequencePtr; -typedef ::IceInternal::Handle<Dictionary> DictionaryPtr; -typedef ::IceInternal::Handle<Enum> EnumPtr; -typedef ::IceInternal::Handle<Enumerator> EnumeratorPtr; -typedef ::IceInternal::Handle<Native> NativePtr; -typedef ::IceInternal::Handle<Unit> UnitPtr; +typedef ::Ice::Handle<GrammerBase> GrammerBasePtr; +typedef ::Ice::Handle<SyntaxTreeBase> SyntaxTreeBasePtr; +typedef ::Ice::Handle<Type> TypePtr; +typedef ::Ice::Handle<Builtin> BuiltinPtr; +typedef ::Ice::Handle<Contained> ContainedPtr; +typedef ::Ice::Handle<Container> ContainerPtr; +typedef ::Ice::Handle<Module> ModulePtr; +typedef ::Ice::Handle<Constructed> ConstructedPtr; +typedef ::Ice::Handle<ClassDecl> ClassDeclPtr; +typedef ::Ice::Handle<ClassDef> ClassDefPtr; +typedef ::Ice::Handle<Proxy> ProxyPtr; +typedef ::Ice::Handle<Struct> StructPtr; +typedef ::Ice::Handle<Operation> OperationPtr; +typedef ::Ice::Handle<DataMember> DataMemberPtr; +typedef ::Ice::Handle<Sequence> SequencePtr; +typedef ::Ice::Handle<Dictionary> DictionaryPtr; +typedef ::Ice::Handle<Enum> EnumPtr; +typedef ::Ice::Handle<Enumerator> EnumeratorPtr; +typedef ::Ice::Handle<Native> NativePtr; +typedef ::Ice::Handle<Unit> UnitPtr; } @@ -128,8 +87,8 @@ int yyparse(); // I must set the initial stack depth to the maximum stack depth to // disable bison stack resizing. The bison stack resizing routines use // simple malloc/alloc/memcpy calls, which do not work for the -// YYSTYPE, since YYSTYPE is a C++ smart pointer, with a default -// constructor and a destructor. +// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor, +// assignment operator, etc. // #define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum. #define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above. @@ -156,7 +115,7 @@ typedef std::list<DataMemberPtr> DataMemberList; // ParserVisitor // ---------------------------------------------------------------------- -class ICE_API ParserVisitor +class SLICE_API ParserVisitor { public: @@ -182,7 +141,7 @@ public: // GrammerBase // ---------------------------------------------------------------------- -class ICE_API GrammerBase : public ::IceInternal::SimpleShared +class SLICE_API GrammerBase : public ::Ice::SimpleShared { }; @@ -190,7 +149,7 @@ class ICE_API GrammerBase : public ::IceInternal::SimpleShared // SyntaxTreeBase // ---------------------------------------------------------------------- -class ICE_API SyntaxTreeBase : public GrammerBase +class SLICE_API SyntaxTreeBase : public GrammerBase { public: @@ -209,7 +168,7 @@ protected: // Type // ---------------------------------------------------------------------- -class ICE_API Type : virtual public SyntaxTreeBase +class SLICE_API Type : virtual public SyntaxTreeBase { public: @@ -222,7 +181,7 @@ protected: // Builtin // ---------------------------------------------------------------------- -class ICE_API Builtin : virtual public Type +class SLICE_API Builtin : virtual public Type { public: @@ -246,7 +205,7 @@ public: protected: Builtin(const UnitPtr&, Kind); - friend class ICE_API Unit; + friend class SLICE_API Unit; Kind _kind; }; @@ -255,7 +214,7 @@ protected: // Contained // ---------------------------------------------------------------------- -class ICE_API Contained : virtual public SyntaxTreeBase +class SLICE_API Contained : virtual public SyntaxTreeBase { public: @@ -283,7 +242,7 @@ public: protected: Contained(const ContainerPtr&, const std::string&); - friend class ICE_API Container; + friend class SLICE_API Container; ContainerPtr _container; std::string _name; @@ -291,14 +250,14 @@ protected: std::string _comment; }; -bool ICE_API operator<(Contained&, Contained&); -bool ICE_API operator==(Contained&, Contained&); +bool SLICE_API operator<(Contained&, Contained&); +bool SLICE_API operator==(Contained&, Contained&); // ---------------------------------------------------------------------- // Container // ---------------------------------------------------------------------- -class ICE_API Container : virtual public SyntaxTreeBase +class SLICE_API Container : virtual public SyntaxTreeBase { public: @@ -346,7 +305,7 @@ protected: // Module // ---------------------------------------------------------------------- -class ICE_API Module : virtual public Container, virtual public Contained +class SLICE_API Module : virtual public Container, virtual public Contained { public: @@ -356,14 +315,14 @@ public: protected: Module(const ContainerPtr&, const std::string&); - friend class ICE_API Container; + friend class SLICE_API Container; }; // ---------------------------------------------------------------------- // Constructed // ---------------------------------------------------------------------- -class ICE_API Constructed : virtual public Type, virtual public Contained +class SLICE_API Constructed : virtual public Type, virtual public Contained { public: @@ -376,7 +335,7 @@ protected: // ClassDecl // ---------------------------------------------------------------------- -class ICE_API ClassDecl : virtual public Constructed +class SLICE_API ClassDecl : virtual public Constructed { public: @@ -389,8 +348,8 @@ public: protected: ClassDecl(const ContainerPtr&, const std::string&, bool, bool); - friend class ICE_API Container; - friend class ICE_API ClassDef; + friend class SLICE_API Container; + friend class SLICE_API ClassDef; ClassDefPtr _definition; bool _local; @@ -401,7 +360,7 @@ protected: // ClassDef // ---------------------------------------------------------------------- -class ICE_API ClassDef : virtual public Container, virtual public Contained +class SLICE_API ClassDef : virtual public Container, virtual public Contained { public: @@ -422,7 +381,7 @@ public: protected: ClassDef(const ContainerPtr&, const std::string&, bool, bool, const ClassList&); - friend class ICE_API Container; + friend class SLICE_API Container; bool _local; bool _interface; @@ -433,7 +392,7 @@ protected: // Proxy // ---------------------------------------------------------------------- -class ICE_API Proxy : virtual public Type +class SLICE_API Proxy : virtual public Type { public: @@ -450,7 +409,7 @@ protected: // Struct // ---------------------------------------------------------------------- -class ICE_API Struct : virtual public Container, virtual public Constructed +class SLICE_API Struct : virtual public Container, virtual public Constructed { public: @@ -462,14 +421,14 @@ public: protected: Struct(const ContainerPtr&, const std::string&); - friend class ICE_API Container; + friend class SLICE_API Container; }; // ---------------------------------------------------------------------- // Operation // ---------------------------------------------------------------------- -class ICE_API Operation : virtual public Contained +class SLICE_API Operation : virtual public Contained { public: @@ -485,7 +444,7 @@ protected: Operation(const ContainerPtr&, const std::string&, const TypePtr&, const TypeStringList&, const TypeStringList&, const TypeList&, bool); - friend class ICE_API ClassDef; + friend class SLICE_API ClassDef; TypePtr _returnType; TypeStringList _inParams; @@ -498,7 +457,7 @@ protected: // DataMember // ---------------------------------------------------------------------- -class ICE_API DataMember : virtual public Contained +class SLICE_API DataMember : virtual public Contained { public: @@ -509,8 +468,8 @@ public: protected: DataMember(const ContainerPtr&, const std::string&, const TypePtr&); - friend class ICE_API ClassDef; - friend class ICE_API Struct; + friend class SLICE_API ClassDef; + friend class SLICE_API Struct; TypePtr _type; }; @@ -519,7 +478,7 @@ protected: // Sequence // ---------------------------------------------------------------------- -class ICE_API Sequence : virtual public Constructed +class SLICE_API Sequence : virtual public Constructed { public: @@ -530,7 +489,7 @@ public: protected: Sequence(const ContainerPtr&, const std::string&, const TypePtr&); - friend class ICE_API Container; + friend class SLICE_API Container; TypePtr _type; }; @@ -539,7 +498,7 @@ protected: // Dictionary // ---------------------------------------------------------------------- -class ICE_API Dictionary : virtual public Constructed +class SLICE_API Dictionary : virtual public Constructed { public: @@ -551,7 +510,7 @@ public: protected: Dictionary(const ContainerPtr&, const std::string&, const TypePtr&, const TypePtr&); - friend class ICE_API Container; + friend class SLICE_API Container; TypePtr _keyType; TypePtr _valueType; @@ -561,7 +520,7 @@ protected: // Enum // ---------------------------------------------------------------------- -class ICE_API Enum : virtual public Constructed +class SLICE_API Enum : virtual public Constructed { public: @@ -572,7 +531,7 @@ public: protected: Enum(const ContainerPtr&, const std::string&, const StringList&); - friend class ICE_API Container; + friend class SLICE_API Container; StringList _enumerators; }; @@ -581,7 +540,7 @@ protected: // Enumerator // ---------------------------------------------------------------------- -class ICE_API Enumerator : virtual public Contained +class SLICE_API Enumerator : virtual public Contained { public: @@ -590,7 +549,7 @@ public: protected: Enumerator(const ContainerPtr&, const std::string&); - friend class ICE_API Container; + friend class SLICE_API Container; }; // ---------------------------------------------------------------------- @@ -614,7 +573,7 @@ protected: // Unit // ---------------------------------------------------------------------- -class ICE_API Unit : virtual public Container +class SLICE_API Unit : virtual public Container { public: diff --git a/cpp/src/Ice/Acceptor.h b/cpp/src/Ice/Acceptor.h index 9c26905334b..bb128910285 100644 --- a/cpp/src/Ice/Acceptor.h +++ b/cpp/src/Ice/Acceptor.h @@ -18,7 +18,7 @@ namespace IceInternal { -class Acceptor : public Shared +class Acceptor : public ::Ice::Shared { public: diff --git a/cpp/src/Ice/Collector.cpp b/cpp/src/Ice/Collector.cpp index bc40066723f..e8eea7c8bfe 100644 --- a/cpp/src/Ice/Collector.cpp +++ b/cpp/src/Ice/Collector.cpp @@ -525,7 +525,8 @@ IceInternal::CollectorFactory::message(Stream&) // // Can't use _collectors.remove_if(constMemFun(...)), because VC++ // doesn't support member templates :-( - _collectors.erase(remove_if(_collectors.begin(), _collectors.end(), constMemFun(&Collector::destroyed)), + _collectors.erase(remove_if(_collectors.begin(), _collectors.end(), + ::IceInternal::constMemFun(&Collector::destroyed)), _collectors.end()); // @@ -635,7 +636,7 @@ IceInternal::CollectorFactory::setState(State state) _threadPool->_register(_acceptor->fd(), this); } - for_each(_collectors.begin(), _collectors.end(), voidMemFun(&Collector::activate)); + for_each(_collectors.begin(), _collectors.end(), ::IceInternal::voidMemFun(&Collector::activate)); break; } @@ -651,7 +652,7 @@ IceInternal::CollectorFactory::setState(State state) _threadPool->unregister(_acceptor->fd()); } - for_each(_collectors.begin(), _collectors.end(), voidMemFun(&Collector::hold)); + for_each(_collectors.begin(), _collectors.end(), ::IceInternal::voidMemFun(&Collector::hold)); break; } @@ -674,7 +675,7 @@ IceInternal::CollectorFactory::setState(State state) _threadPool->unregister(_acceptor->fd()); } } - for_each(_collectors.begin(), _collectors.end(), voidMemFun(&Collector::destroy)); + for_each(_collectors.begin(), _collectors.end(), ::IceInternal::voidMemFun(&Collector::destroy)); _collectors.clear(); break; } diff --git a/cpp/src/Ice/Connector.h b/cpp/src/Ice/Connector.h index 12c6267567c..b5a8f8b34ec 100644 --- a/cpp/src/Ice/Connector.h +++ b/cpp/src/Ice/Connector.h @@ -18,7 +18,7 @@ namespace IceInternal { -class Connector : public Shared +class Connector : public ::Ice::Shared { public: diff --git a/cpp/src/Ice/Emitter.h b/cpp/src/Ice/Emitter.h index f9e261b35fc..5d33c2b173d 100644 --- a/cpp/src/Ice/Emitter.h +++ b/cpp/src/Ice/Emitter.h @@ -88,7 +88,7 @@ private: #endif }; -class EmitterFactory : public Shared, public JTCMutex +class EmitterFactory : public ::Ice::Shared, public JTCMutex { public: diff --git a/cpp/src/Ice/Endpoint.h b/cpp/src/Ice/Endpoint.h index c364099fe2f..ff0ed6b23de 100644 --- a/cpp/src/Ice/Endpoint.h +++ b/cpp/src/Ice/Endpoint.h @@ -28,7 +28,7 @@ const ::Ice::Short TcpEndpointType = 1; const ::Ice::Short SslEndpointType = 2; const ::Ice::Short UdpEndpointType = 3; -class Endpoint : public Shared +class Endpoint : public ::Ice::Shared { public: diff --git a/cpp/src/Ice/EventHandler.h b/cpp/src/Ice/EventHandler.h index 1fea0a0b3a6..2ddfd36d354 100644 --- a/cpp/src/Ice/EventHandler.h +++ b/cpp/src/Ice/EventHandler.h @@ -27,7 +27,7 @@ class LocalException; namespace IceInternal { -class EventHandler : public Shared +class EventHandler : public ::Ice::Shared { public: diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index 6548e9eb36a..841c3dc98ea 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -34,7 +34,7 @@ class CommunicatorI; namespace IceInternal { -class Instance : public Shared, public JTCMutex +class Instance : public ::Ice::Shared, public JTCMutex { public: diff --git a/cpp/src/Ice/Makefile b/cpp/src/Ice/Makefile index 803238f7b97..00e48fa048e 100644 --- a/cpp/src/Ice/Makefile +++ b/cpp/src/Ice/Makefile @@ -18,8 +18,7 @@ VERSIONED_NAME = $(top_srcdir)/lib/$(VERSIONED_BASE) TARGETS = $(NAME) $(VERSIONED_NAME) -OBJS = Shared.o \ - Stream.o \ +OBJS = Stream.o \ LocalException.o \ Pickler.o \ PicklerI.o \ diff --git a/cpp/src/Ice/ObjectAdapterFactory.cpp b/cpp/src/Ice/ObjectAdapterFactory.cpp index 0df7b32816f..f0f520b737c 100644 --- a/cpp/src/Ice/ObjectAdapterFactory.cpp +++ b/cpp/src/Ice/ObjectAdapterFactory.cpp @@ -26,7 +26,8 @@ void IceInternal::ObjectAdapterFactory::shutdown() { JTCSyncT<JTCMutex> sync(*this); - for_each(_adapters.begin(), _adapters.end(), secondVoidMemFun<string, ObjectAdapter>(&ObjectAdapter::deactivate)); + for_each(_adapters.begin(), _adapters.end(), + ::IceInternal::secondVoidMemFun<string, ObjectAdapter>(&ObjectAdapter::deactivate)); _adapters.clear(); } diff --git a/cpp/src/Ice/ObjectAdapterFactory.h b/cpp/src/Ice/ObjectAdapterFactory.h index d8f9e394ad4..6507a92fc9d 100644 --- a/cpp/src/Ice/ObjectAdapterFactory.h +++ b/cpp/src/Ice/ObjectAdapterFactory.h @@ -22,7 +22,7 @@ namespace IceInternal { -class ObjectAdapterFactory : public Shared, public JTCMutex +class ObjectAdapterFactory : public ::Ice::Shared, public JTCMutex { public: diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 468293b242c..4549106a002 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -53,7 +53,7 @@ Ice::ObjectAdapterI::activate() } for_each(_collectorFactories.begin(), _collectorFactories.end(), - voidMemFun(& ::IceInternal::CollectorFactory::activate)); + ::IceInternal::voidMemFun(& ::IceInternal::CollectorFactory::activate)); } void @@ -67,7 +67,7 @@ Ice::ObjectAdapterI::hold() } for_each(_collectorFactories.begin(), _collectorFactories.end(), - voidMemFun(& ::IceInternal::CollectorFactory::hold)); + ::IceInternal::voidMemFun(& ::IceInternal::CollectorFactory::hold)); } void @@ -81,7 +81,7 @@ Ice::ObjectAdapterI::deactivate() } for_each(_collectorFactories.begin(), _collectorFactories.end(), - voidMemFun(& ::IceInternal::CollectorFactory::destroy)); + ::IceInternal::voidMemFun(& ::IceInternal::CollectorFactory::destroy)); _collectorFactories.clear(); _objects.clear(); } @@ -240,7 +240,7 @@ Ice::ObjectAdapterI::identityToProxy(const string& ident) vector<EndpointPtr> endpoints; transform(_collectorFactories.begin(), _collectorFactories.end(), back_inserter(endpoints), - constMemFun(&CollectorFactory::endpoint)); + ::IceInternal::constMemFun(&CollectorFactory::endpoint)); ReferencePtr reference = new Reference(_instance, ident, Reference::ModeTwoway, false, endpoints, endpoints); return _instance->proxyFactory()->referenceToProxy(reference); diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index f80f0a17eed..87643fd767a 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -88,7 +88,7 @@ IceProxy::Ice::Object::_isA(const string& s) { try { - Handle< ::IceDelegate::Ice::Object> __del = __getDelegate(); + ::IceInternal::Handle< ::IceDelegate::Ice::Object> __del = __getDelegate(); return __del->_isA(s); } catch (const LocationForward& __ex) @@ -114,7 +114,7 @@ IceProxy::Ice::Object::_ping() { try { - Handle< ::IceDelegate::Ice::Object> __del = __getDelegate(); + ::IceInternal::Handle< ::IceDelegate::Ice::Object> __del = __getDelegate(); __del->_ping(); return; } @@ -136,7 +136,7 @@ IceProxy::Ice::Object::_ping() void IceProxy::Ice::Object::_flush() { - Handle< ::IceDelegate::Ice::Object> __del = __getDelegate(); + ::IceInternal::Handle< ::IceDelegate::Ice::Object> __del = __getDelegate(); __del->_flush(); } @@ -409,7 +409,7 @@ IceProxy::Ice::Object::~Object() { } -Handle< ::IceDelegate::Ice::Object> +::IceInternal::Handle< ::IceDelegate::Ice::Object> IceProxy::Ice::Object::__getDelegate() { JTCSyncT<JTCMutex> sync(*this); @@ -432,10 +432,10 @@ IceProxy::Ice::Object::__getDelegate() return _delegate; } -Handle< ::IceDelegateM::Ice::Object> +::IceInternal::Handle< ::IceDelegateM::Ice::Object> IceProxy::Ice::Object::__createDelegateM() { - return Handle< ::IceDelegateM::Ice::Object>(new ::IceDelegateM::Ice::Object); + return ::IceInternal::Handle< ::IceDelegateM::Ice::Object>(new ::IceDelegateM::Ice::Object); } void @@ -538,7 +538,7 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& reference) case Reference::ModeBatchOneway: { remove_copy_if(_reference->endpoints.begin(), _reference->endpoints.end(), back_inserter(endpoints), - not1(constMemFun(&Endpoint::regular))); + not1(::IceInternal::constMemFun(&Endpoint::regular))); break; } @@ -546,14 +546,15 @@ IceDelegateM::Ice::Object::setup(const ReferencePtr& reference) case Reference::ModeBatchDatagram: { remove_copy_if(_reference->endpoints.begin(), _reference->endpoints.end(), back_inserter(endpoints), - not1(constMemFun(&Endpoint::datagram))); + not1(::IceInternal::constMemFun(&Endpoint::datagram))); break; } } if (_reference->secure) { - endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), not1(constMemFun(&Endpoint::secure))), + endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), + not1(::IceInternal::constMemFun(&Endpoint::secure))), endpoints.end()); } diff --git a/cpp/src/Ice/ProxyFactory.h b/cpp/src/Ice/ProxyFactory.h index 9d7df5694d7..f2a831ea152 100644 --- a/cpp/src/Ice/ProxyFactory.h +++ b/cpp/src/Ice/ProxyFactory.h @@ -22,7 +22,7 @@ namespace IceInternal class Stream; -class ProxyFactory : public Shared +class ProxyFactory : public ::Ice::Shared { public: diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index 865477a822f..f5330ff68e5 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -21,7 +21,7 @@ namespace IceInternal class Stream; -class Reference : public Shared +class Reference : public ::Ice::Shared { public: diff --git a/cpp/src/Ice/Shared.cpp b/cpp/src/Ice/Shared.cpp deleted file mode 100644 index 12f3bb88501..00000000000 --- a/cpp/src/Ice/Shared.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#include <Ice/Shared.h> - -using namespace std; -using namespace Ice; -using namespace IceInternal; - -//static int simpleDebugCounter = 0; -//static int debugCounter = 0; -//static JTCMutex debugCounterMutex; - -IceInternal::SimpleShared::SimpleShared() : - _ref(0), - _noDelete(false) -{ -// cout << "new SimpleShared: " << ++simpleDebugCounter << endl; -} - -IceInternal::SimpleShared::~SimpleShared() -{ -// cout << "delete SimpleShared: " << --simpleDebugCounter << endl; -} - -IceInternal::Shared::Shared() : - _ref(0), - _noDelete(false) -{ -// JTCSyncT<JTCMutex> sync(debugCounterMutex); -// cout << "new Shared: " << ++debugCounter << endl; -} - -IceInternal::Shared::~Shared() -{ -// JTCSyncT<JTCMutex> sync(debugCounterMutex); -// cout << "delete Shared: " << --debugCounter << endl; -} diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h index 0c649acedbd..cee7779c223 100644 --- a/cpp/src/Ice/ThreadPool.h +++ b/cpp/src/Ice/ThreadPool.h @@ -22,7 +22,7 @@ namespace IceInternal class Stream; -class ThreadPool : public Shared, public JTCMonitorT<JTCMutex> +class ThreadPool : public ::Ice::Shared, public JTCMonitorT<JTCMutex> { public: diff --git a/cpp/src/Ice/TraceLevels.h b/cpp/src/Ice/TraceLevels.h index f30e5442e77..b764e93ac03 100644 --- a/cpp/src/Ice/TraceLevels.h +++ b/cpp/src/Ice/TraceLevels.h @@ -18,7 +18,7 @@ namespace IceInternal { -class TraceLevels : public Shared +class TraceLevels : public ::Ice::Shared { public: diff --git a/cpp/src/Ice/Transceiver.h b/cpp/src/Ice/Transceiver.h index dc1b292034d..89460b12288 100644 --- a/cpp/src/Ice/Transceiver.h +++ b/cpp/src/Ice/Transceiver.h @@ -19,7 +19,7 @@ namespace IceInternal class Buffer; -class Transceiver : public Shared +class Transceiver : public ::Ice::Shared { public: diff --git a/cpp/src/Ice/ValueFactoryManager.h b/cpp/src/Ice/ValueFactoryManager.h index 1246b866477..5f23e6e3611 100644 --- a/cpp/src/Ice/ValueFactoryManager.h +++ b/cpp/src/Ice/ValueFactoryManager.h @@ -19,7 +19,7 @@ namespace IceInternal { -class ValueFactoryManager : public Shared, public JTCMutex +class ValueFactoryManager : public ::Ice::Shared, public JTCMutex { public: diff --git a/cpp/src/Ice/ice.dsp b/cpp/src/Ice/ice.dsp index 5fa32da7baa..8fadf57fcaa 100644 --- a/cpp/src/Ice/ice.dsp +++ b/cpp/src/Ice/ice.dsp @@ -210,10 +210,6 @@ SOURCE=.\Reference.cpp # End Source File
# Begin Source File
-SOURCE=.\Shared.cpp
-# End Source File
-# Begin Source File
-
SOURCE=.\SslAcceptor.cpp
# End Source File
# Begin Source File
diff --git a/cpp/src/IcePack/Grammer.y b/cpp/src/IcePack/Grammer.y index 8dfef955e99..8eb904530fa 100644 --- a/cpp/src/IcePack/Grammer.y +++ b/cpp/src/IcePack/Grammer.y @@ -25,6 +25,8 @@ yyerror(const char* s) %} +%pure_parser + %token ICE_PACK_STRING %token ICE_PACK_EXIT %token ICE_PACK_ADD diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp index da7cb9be577..a9d26ecbab4 100644 --- a/cpp/src/IcePack/Parser.cpp +++ b/cpp/src/IcePack/Parser.cpp @@ -17,12 +17,16 @@ # define fileno _fileno #endif +#ifdef HAVE_READLINE +# include <readline/readline.h> +# include <readline/history.h> +#endif + using namespace std; using namespace Ice; using namespace IcePack; extern FILE* yyin; -extern const char* yycommands; namespace IcePack { @@ -140,6 +144,98 @@ IcePack::Parser::shutdown() } void +IcePack::Parser::getInput(char* buf, int result, int maxSize) +{ + if (_commands) + { + if (strcmp(_commands, ";") == 0) + { + buf[0] = EOF; + result = 1; + } + else + { + result = strlen(_commands); + if (result >= maxSize) + { + error("fatal error in flex scanner: command line too long"); + buf[0] = EOF; + result = 1; + } + else + { + strcpy(buf, _commands); + _commands = ";"; + } + } + } + else if (isatty(fileno(yyin))) + { +#ifdef HAVE_READLINE + + char* line = readline(parser->getPrompt()); + if (line && *line) + { + add_history(line); + } + if (!line) + { + buf[0] = EOF; + result = 1; + } + else + { + result = strlen(line) + 1; + if (result >= maxSize) + { + free(line); + error("fatal error in flex scanner: input line too long"); + buf[0] = EOF; + result = 1; + } + else + { + strcpy(buf, line); + strcat(buf, "\n"); + free(line); + } + } + +#else + + cout << parser->getPrompt() << flush; + int c = '*'; + int n; + for (n = 0; n < maxSize && (c = getc(yyin)) != EOF && c != '\n'; ++n) + { + buf[n] = static_cast<char>(c); + } + if (c == '\n') + { + buf[n++] = static_cast<char>(c); + } + if (c == EOF && ferror(yyin)) + { + error("input in flex scanner failed"); + buf[0] = EOF; + result = 1; + } + result = n; + +#endif + } + else + { + if (((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) + { + error("input in flex scanner failed"); + buf[0] = EOF; + result = 1; + } + } +} + +void IcePack::Parser::nextLine() { _currentLine++; @@ -154,7 +250,7 @@ IcePack::Parser::continueLine() char* IcePack::Parser::getPrompt() { - assert(!yycommands && isatty(fileno(yyin))); + assert(!_commands && isatty(fileno(yyin))); if (_continue) { @@ -214,7 +310,7 @@ IcePack::Parser::scanPosition(const char* s) void IcePack::Parser::error(const char* s) { - if (!yycommands && !isatty(fileno(yyin))) + if (!_commands && !isatty(fileno(yyin))) { cerr << _currentFile << ':' << _currentLine << ": " << s << endl; } @@ -222,7 +318,7 @@ IcePack::Parser::error(const char* s) { cerr << "error: " << s << endl; } - yynerrs++; + _errors++; } void @@ -234,7 +330,7 @@ IcePack::Parser::error(const string& s) void IcePack::Parser::warning(const char* s) { - if (!yycommands && !isatty(fileno(yyin))) + if (!_commands && !isatty(fileno(yyin))) { cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl; } @@ -259,8 +355,9 @@ IcePack::Parser::parse(FILE* file, bool debug) assert(!parser); parser = this; + _errors = 0; + _commands = 0; yyin = file; - yycommands = 0; _currentFile = "<standard input>"; _currentLine = 0; @@ -268,6 +365,10 @@ IcePack::Parser::parse(FILE* file, bool debug) nextLine(); int status = yyparse(); + if (_errors) + { + status = EXIT_FAILURE; + } parser = 0; return status; @@ -282,8 +383,9 @@ IcePack::Parser::parse(const std::string& commands, bool debug) assert(!parser); parser = this; + _errors = 0; + _commands = commands.c_str(); yyin = 0; - yycommands = commands.c_str(); _currentFile = "<command line>"; _currentLine = 0; @@ -291,6 +393,10 @@ IcePack::Parser::parse(const std::string& commands, bool debug) nextLine(); int status = yyparse(); + if (_errors) + { + status = EXIT_FAILURE; + } parser = 0; return status; diff --git a/cpp/src/IcePack/Parser.h b/cpp/src/IcePack/Parser.h index 42282a010c2..d957978dd1b 100644 --- a/cpp/src/IcePack/Parser.h +++ b/cpp/src/IcePack/Parser.h @@ -14,12 +14,24 @@ #include <IcePack/Admin.h> #include <list> -#define YYSTYPE std::list<std::string> - -extern int yynerrs; +// +// Stuff for flex and bison +// +#define YYSTYPE std::list<std::string> +#define YY_DECL int yylex(YYSTYPE* yylvalp) +YY_DECL; int yyparse(); -int yylex(); + +// +// I must set the initial stack depth to the maximum stack depth to +// disable bison stack resizing. The bison stack resizing routines use +// simple malloc/alloc/memcpy calls, which do not work for the +// YYSTYPE, since YYSTYPE is a C++ type, with constructor, destructor, +// assignment operator, etc. +// +#define YYMAXDEPTH 20000 // 20000 should suffice. Bison default is 10000 as maximum. +#define YYINITDEPTH YYMAXDEPTH // Initial depth is set to max depth, for the reasons described above. namespace IcePack { @@ -57,6 +69,7 @@ public: void getAll(); void shutdown(); + void getInput(char*, int, int); void nextLine(); void continueLine(); char* getPrompt(); @@ -75,9 +88,11 @@ private: Parser(const Ice::CommunicatorPtr&, const IcePack::AdminPrx&); + const char* _commands; Ice::CommunicatorPtr _communicator; IcePack::AdminPrx _admin; bool _continue; + int _errors; int _currentLine; std::string _currentFile; }; diff --git a/cpp/src/IcePack/Scanner.l b/cpp/src/IcePack/Scanner.l index b5cb5519df2..9fe7335714c 100644 --- a/cpp/src/IcePack/Scanner.l +++ b/cpp/src/IcePack/Scanner.l @@ -14,139 +14,11 @@ #include <IcePack/Parser.h> #include <IcePack/Grammer.h> -#ifdef WIN32 -# include <io.h> -# define isatty _isatty -# define fileno _fileno -// '_isatty' : inconsistent dll linkage. dllexport assumed. -# pragma warning( disable : 4273 ) -#endif - using namespace std; using namespace Ice; using namespace IcePack; -const char* yycommands; - -#ifdef HAVE_READLINE - -# include <readline/readline.h> -# include <readline/history.h> - -# define YY_INPUT(buf, result, maxSize) \ -\ -if (yycommands) \ -{ \ - if (strcmp(yycommands, ";") == 0) \ - { \ - buf[0] = EOF; \ - result = 1; \ - } \ - else \ - { \ - result = strlen(yycommands); \ - if (result >= maxSize) \ - { \ - YY_FATAL_ERROR("fatal error in flex scanner: command line too long"); \ - } \ - else \ - { \ - strcpy(buf, yycommands); \ - yycommands = ";"; \ - } \ - }\ -} \ -else if (yy_current_buffer->yy_is_interactive) \ -{ \ - char* line = readline(parser->getPrompt()); \ - if (line && *line) \ - { \ - add_history(line); \ - } \ - if (!line) \ - { \ - buf[0] = EOF; \ - result = 1; \ - } \ - else \ - { \ - result = strlen(line) + 1; \ - if (result >= maxSize) \ - { \ - free(line); \ - YY_FATAL_ERROR("fatal error in flex scanner: input line too long"); \ - } \ - else \ - { \ - strcpy(buf, line); \ - strcat(buf, "\n"); \ - free(line); \ - } \ - } \ -} \ -else \ -{ \ - if (((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) \ - { \ - YY_FATAL_ERROR("input in flex scanner failed"); \ - } \ -} - -#else - -# define YY_INPUT(buf, result, maxSize) \ -\ -if (yycommands) \ -{ \ - if (strcmp(yycommands, ";") == 0) \ - { \ - buf[0] = EOF; \ - result = 1; \ - } \ - else \ - { \ - result = strlen(yycommands); \ - if (result >= maxSize) \ - { \ - YY_FATAL_ERROR("fatal error in flex scanner: command line too long"); \ - } \ - else \ - { \ - strcpy(buf, yycommands); \ - yycommands = ";"; \ - } \ - }\ -} \ -else if (yy_current_buffer->yy_is_interactive) \ -{ \ - if (isatty(fileno(yyin))) \ - { \ - cout << parser->getPrompt() << flush; \ - } \ - int c = '*', n; \ - for (n = 0; n < maxSize && (c = getc(yyin)) != EOF && c != '\n'; ++n ) \ - { \ - buf[n] = (char)c; \ - } \ - if (c == '\n') \ - { \ - buf[n++] = (char)c; \ - } \ - if (c == EOF && ferror(yyin)) \ - { \ - YY_FATAL_ERROR("input in flex scanner failed"); \ - } \ - result = n; \ -} \ -else \ -{ \ - if (((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) \ - { \ - YY_FATAL_ERROR("input in flex scanner failed"); \ - } \ -} - -#endif +#define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize) %} @@ -293,8 +165,8 @@ L [a-zA-Z_] s += c; } } - yylval.clear(); - yylval.push_back(s); + yylvalp->clear(); + yylvalp->push_back(s); return ICE_PACK_STRING; } @@ -323,8 +195,8 @@ L [a-zA-Z_] s += c; } } - yylval.clear(); - yylval.push_back(s); + yylvalp->clear(); + yylvalp->push_back(s); return ICE_PACK_STRING; } diff --git a/cpp/src/Slice/GrammerUtil.cpp b/cpp/src/Slice/GrammerUtil.cpp deleted file mode 100644 index a27c390f169..00000000000 --- a/cpp/src/Slice/GrammerUtil.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2001 -// MutableRealms, Inc. -// Huntsville, AL, USA -// -// All Rights Reserved -// -// ********************************************************************** - -#include <Slice/GrammerUtil.h> - -using namespace std; -using namespace Slice; - -void IceInternal::incRef(StringTok* p) { p->__incRef(); } -void IceInternal::decRef(StringTok* p) { p->__decRef(); } -void IceInternal::incRef(TypeStringListTok* p) { p->__incRef(); } -void IceInternal::decRef(TypeStringListTok* p) { p->__decRef(); } -void IceInternal::incRef(StringListTok* p) { p->__incRef(); } -void IceInternal::decRef(StringListTok* p) { p->__decRef(); } -void IceInternal::incRef(BoolTok* p) { p->__incRef(); } -void IceInternal::decRef(BoolTok* p) { p->__decRef(); } -void IceInternal::incRef(TypeListTok* p) { p->__incRef(); } -void IceInternal::decRef(TypeListTok* p) { p->__decRef(); } -void IceInternal::incRef(ClassListTok* p) { p->__incRef(); } -void IceInternal::decRef(ClassListTok* p) { p->__decRef(); } diff --git a/cpp/src/Slice/GrammerUtil.h b/cpp/src/Slice/GrammerUtil.h index 258955dc1cb..7dc3c54a008 100644 --- a/cpp/src/Slice/GrammerUtil.h +++ b/cpp/src/Slice/GrammerUtil.h @@ -23,35 +23,12 @@ class BoolTok; class TypeListTok; class ClassListTok; -} - -namespace IceInternal -{ - -void ICE_API incRef(::Slice::StringTok*); -void ICE_API decRef(::Slice::StringTok*); -void ICE_API incRef(::Slice::TypeStringListTok*); -void ICE_API decRef(::Slice::TypeStringListTok*); -void ICE_API incRef(::Slice::StringListTok*); -void ICE_API decRef(::Slice::StringListTok*); -void ICE_API incRef(::Slice::BoolTok*); -void ICE_API decRef(::Slice::BoolTok*); -void ICE_API incRef(::Slice::TypeListTok*); -void ICE_API decRef(::Slice::TypeListTok*); -void ICE_API incRef(::Slice::ClassListTok*); -void ICE_API decRef(::Slice::ClassListTok*); - -} - -namespace Slice -{ - -typedef ::IceInternal::Handle<StringTok> StringTokPtr; -typedef ::IceInternal::Handle<TypeStringListTok> TypeStringListTokPtr; -typedef ::IceInternal::Handle<StringListTok> StringListTokPtr; -typedef ::IceInternal::Handle<BoolTok> BoolTokPtr; -typedef ::IceInternal::Handle<TypeListTok> TypeListTokPtr; -typedef ::IceInternal::Handle<ClassListTok> ClassListTokPtr; +typedef ::Ice::Handle<StringTok> StringTokPtr; +typedef ::Ice::Handle<TypeStringListTok> TypeStringListTokPtr; +typedef ::Ice::Handle<StringListTok> StringListTokPtr; +typedef ::Ice::Handle<BoolTok> BoolTokPtr; +typedef ::Ice::Handle<TypeListTok> TypeListTokPtr; +typedef ::Ice::Handle<ClassListTok> ClassListTokPtr; } diff --git a/cpp/src/Slice/Makefile b/cpp/src/Slice/Makefile index 7c08096d7c1..950b45e91a4 100644 --- a/cpp/src/Slice/Makefile +++ b/cpp/src/Slice/Makefile @@ -18,10 +18,8 @@ VERSIONED_NAME = $(top_srcdir)/lib/$(VERSIONED_BASE) TARGETS = $(NAME) $(VERSIONED_NAME) -OBJS = Shared.o \ - Scanner.o \ +OBJS = Scanner.o \ Grammer.o \ - GrammerUtil.o \ Parser.o \ OutputUtil.o @@ -52,11 +50,4 @@ clean:: -rm -f Grammer.cpp Grammer.h Grammer.output -rm -f Scanner.cpp lex.yy.c -Shared.cpp: ../Ice/Shared.cpp - rm -f $@ - ln -s ../Ice/Shared.cpp $@ - -clean:: - -rm -f Shared.cpp - include .depend diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 856c60026b5..bc4c20fef7e 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -21,47 +21,6 @@ Unit* unit; } -void IceInternal::incRef(GrammerBase* p) { p->__incRef(); } -void IceInternal::decRef(GrammerBase* p) { p->__decRef(); } -void IceInternal::incRef(SyntaxTreeBase* p) { p->__incRef(); } -void IceInternal::decRef(SyntaxTreeBase* p) { p->__decRef(); } -void IceInternal::incRef(Type* p) { p->__incRef(); } -void IceInternal::decRef(Type* p) { p->__decRef(); } -void IceInternal::incRef(Builtin* p) { p->__incRef(); } -void IceInternal::decRef(Builtin* p) { p->__decRef(); } -void IceInternal::incRef(Contained* p) { p->__incRef(); } -void IceInternal::decRef(Contained* p) { p->__decRef(); } -void IceInternal::incRef(Container* p) { p->__incRef(); } -void IceInternal::decRef(Container* p) { p->__decRef(); } -void IceInternal::incRef(Module* p) { p->__incRef(); } -void IceInternal::decRef(Module* p) { p->__decRef(); } -void IceInternal::incRef(Constructed* p) { p->__incRef(); } -void IceInternal::decRef(Constructed* p) { p->__decRef(); } -void IceInternal::incRef(ClassDecl* p) { p->__incRef(); } -void IceInternal::decRef(ClassDecl* p) { p->__decRef(); } -void IceInternal::incRef(ClassDef* p) { p->__incRef(); } -void IceInternal::decRef(ClassDef* p) { p->__decRef(); } -void IceInternal::incRef(Proxy* p) { p->__incRef(); } -void IceInternal::decRef(Proxy* p) { p->__decRef(); } -void IceInternal::incRef(Struct* p) { p->__incRef(); } -void IceInternal::decRef(Struct* p) { p->__decRef(); } -void IceInternal::incRef(Operation* p) { p->__incRef(); } -void IceInternal::decRef(Operation* p) { p->__decRef(); } -void IceInternal::incRef(DataMember* p) { p->__incRef(); } -void IceInternal::decRef(DataMember* p) { p->__decRef(); } -void IceInternal::incRef(Sequence* p) { p->__incRef(); } -void IceInternal::decRef(Sequence* p) { p->__decRef(); } -void IceInternal::incRef(Dictionary* p) { p->__incRef(); } -void IceInternal::decRef(Dictionary* p) { p->__decRef(); } -void IceInternal::incRef(Enum* p) { p->__incRef(); } -void IceInternal::decRef(Enum* p) { p->__decRef(); } -void IceInternal::incRef(Enumerator* p) { p->__incRef(); } -void IceInternal::decRef(Enumerator* p) { p->__decRef(); } -void IceInternal::incRef(Native* p) { p->__incRef(); } -void IceInternal::decRef(Native* p) { p->__decRef(); } -void IceInternal::incRef(Unit* p) { p->__incRef(); } -void IceInternal::decRef(Unit* p) { p->__decRef(); } - // ---------------------------------------------------------------------- // SyntaxTreeBase // ---------------------------------------------------------------------- diff --git a/cpp/src/Slice/slice.dsp b/cpp/src/Slice/slice.dsp index fbc63c2948c..9b3c090d983 100644 --- a/cpp/src/Slice/slice.dsp +++ b/cpp/src/Slice/slice.dsp @@ -106,10 +106,6 @@ SOURCE=.\Grammer.cpp # End Source File
# Begin Source File
-SOURCE=.\GrammerUtil.cpp
-# End Source File
-# Begin Source File
-
SOURCE=.\OutputUtil.cpp
# End Source File
# Begin Source File
@@ -120,10 +116,6 @@ SOURCE=.\Parser.cpp SOURCE=.\Scanner.cpp
# End Source File
-# Begin Source File
-
-SOURCE=..\Ice\Shared.cpp
-# End Source File
# End Group
# Begin Group "Header Files"
diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 77002b264a3..18a62288adc 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -17,7 +17,7 @@ namespace Slice { -class Gen : ::IceInternal::noncopyable +class Gen : public ::Ice::noncopyable { public: @@ -45,7 +45,7 @@ private: std::vector<std::string> _includePaths; std::string _dllExport; - class TypesVisitor : ::IceInternal::noncopyable, public ParserVisitor + class TypesVisitor : public ::Ice::noncopyable, public ParserVisitor { public: @@ -66,7 +66,7 @@ private: std::string _dllExport; }; - class ProxyDeclVisitor : ::IceInternal::noncopyable, public ParserVisitor + class ProxyDeclVisitor : public ::Ice::noncopyable, public ParserVisitor { public: @@ -86,7 +86,7 @@ private: std::string _dllExport; }; - class ProxyVisitor : ::IceInternal::noncopyable, public ParserVisitor + class ProxyVisitor : public ::Ice::noncopyable, public ParserVisitor { public: @@ -108,7 +108,7 @@ private: std::string _dllExport; }; - class DelegateVisitor : ::IceInternal::noncopyable, public ParserVisitor + class DelegateVisitor : public ::Ice::noncopyable, public ParserVisitor { public: @@ -130,7 +130,7 @@ private: std::string _dllExport; }; - class DelegateMVisitor : ::IceInternal::noncopyable, public ParserVisitor + class DelegateMVisitor : public ::Ice::noncopyable, public ParserVisitor { public: @@ -152,7 +152,7 @@ private: std::string _dllExport; }; - class ObjectDeclVisitor : ::IceInternal::noncopyable, public ParserVisitor + class ObjectDeclVisitor : public ::Ice::noncopyable, public ParserVisitor { public: @@ -170,7 +170,7 @@ private: std::string _dllExport; }; - class ObjectVisitor : ::IceInternal::noncopyable, public ParserVisitor + class ObjectVisitor : public ::Ice::noncopyable, public ParserVisitor { public: @@ -191,7 +191,7 @@ private: std::string _dllExport; }; - class IceVisitor : ::IceInternal::noncopyable, public ParserVisitor + class IceVisitor : public ::Ice::noncopyable, public ParserVisitor { public: @@ -210,7 +210,7 @@ private: std::string _dllExport; }; - class HandleVisitor : ::IceInternal::noncopyable, public ParserVisitor + class HandleVisitor : public ::Ice::noncopyable, public ParserVisitor { public: diff --git a/cpp/src/slice2docbook/Gen.h b/cpp/src/slice2docbook/Gen.h index 86fcc9c881f..88db0e266ba 100644 --- a/cpp/src/slice2docbook/Gen.h +++ b/cpp/src/slice2docbook/Gen.h @@ -18,7 +18,7 @@ namespace Slice { -class Gen : ::IceInternal::noncopyable, public ParserVisitor +class Gen : public ::Ice::noncopyable, public ParserVisitor { public: |