diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-04-07 08:20:09 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-04-07 08:20:09 +0200 |
commit | bfab72e50fe8b94bd3a7dbcf63114002008575ea (patch) | |
tree | c3bcb603a500f4f42e694514f7fba86570024390 /zend | |
parent | 6d05c17a8d00075f1578094163237c43128e1df9 (diff) |
very simple non-working implementation of streambufs for hhvm
Diffstat (limited to 'zend')
-rw-r--r-- | zend/includes.h | 2 | ||||
-rw-r--r-- | zend/streambuf.cpp | 38 | ||||
-rw-r--r-- | zend/streambuf.h | 80 |
3 files changed, 1 insertions, 119 deletions
diff --git a/zend/includes.h b/zend/includes.h index 50eb4d5..274ad85 100644 --- a/zend/includes.h +++ b/zend/includes.h @@ -79,6 +79,7 @@ * Common header files for internal use only */ #include "../common/extensionbase.h" +#include "../common/streambuf.h" /** * Specific zend implementation files for internal use only @@ -102,7 +103,6 @@ #include "invaliditerator.h" #include "traverseiterator.h" #include "iteratorimpl.h" -#include "streambuf.h" #include "classimpl.h" #include "objectimpl.h" #include "parametersimpl.h" diff --git a/zend/streambuf.cpp b/zend/streambuf.cpp index e258b4e..86e5f03 100644 --- a/zend/streambuf.cpp +++ b/zend/streambuf.cpp @@ -16,44 +16,6 @@ namespace Php { /** - * Constructor - * @param error - */ -StreamBuf::StreamBuf(int error) : _error(error) -{ - // we reserve one byte, so that when overflow is called, we still have one - // byte extra in the buffer to put the overflowed byte int - setp(_buffer, _buffer+1024-1); -} - - -/** - * Method that is called when the internal buffer overflows - * @param c - * @return int - */ -int StreamBuf::overflow(int c) -{ - // for error buffers, overflow is simply discarded - if (_error) return c; - - // end-of-file has not output, we call EOF directly, and by using the - // comma operator we ensure that EOF is returned - if (c == EOF) return sync(), EOF; - - // because we lied the underlying buffer about the size of the buffer - // by one byte, there is no real overflow, and we can still add the byte - // to the end of the buffer - *pptr() = c; - - // increment buffer size - pbump(1); - - // and now we're going to syn the buffer - return sync() == -1 ? EOF : c; -} - -/** * Called when the internal buffer should be synchronized * @return int */ diff --git a/zend/streambuf.h b/zend/streambuf.h deleted file mode 100644 index ed1506a..0000000 --- a/zend/streambuf.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * StreamBuf.h - * - * PHP output stream buffer which is used by the Php::out object to - * have an output stream just like the regular std::ostream buffers, - * but that sends all output to PHP output - * - * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> - * @copyright 2014 Copernica BV - */ - -/** - * Set up namespace - */ -namespace Php { - -/** - * Class definition - */ -class StreamBuf : public std::streambuf -{ -public: - /** - * Constructor - * @param error the error type, or 0 for regular output - */ - StreamBuf(int error); - - /** - * No copying or moving - * @param that - */ - StreamBuf(const StreamBuf &that) = delete; - StreamBuf(StreamBuf &&that) = delete; - - /** - * Destructor - */ - virtual ~StreamBuf() {} - - /** - * No copying or moving - * @param that - */ - StreamBuf &operator=(const StreamBuf &that) = delete; - StreamBuf &operator=(StreamBuf &&that) = delete; - -protected: - /** - * Method that is called when the internal buffer overflows - * @param c - * @return int - */ - virtual int overflow(int c = EOF) override; - - /** - * Called when the internal buffer should be synchronized - * @return int - */ - virtual int sync() override; - -private: - /** - * The error type, or 0 for regular output - * @var int - */ - int _error; - - /** - * The internal buffer - * @var char[] - */ - char _buffer[1024]; -}; - -/** - * End namespace - */ -} - |