helly           Mon Nov  1 10:50:26 2004 EDT

  Added files:                 
    /php-src/ext/spl    spl_exceptions.c spl_exceptions.h 

  Modified files:              
    /php-src/ext/spl    config.m4 config.w32 php_spl.c spl.php 
  Log:
  - Implement basic exception classes
  
  
http://cvs.php.net/diff.php/php-src/ext/spl/config.m4?r1=1.11&r2=1.12&ty=u
Index: php-src/ext/spl/config.m4
diff -u php-src/ext/spl/config.m4:1.11 php-src/ext/spl/config.m4:1.12
--- php-src/ext/spl/config.m4:1.11      Sun Jul 18 08:03:51 2004
+++ php-src/ext/spl/config.m4   Mon Nov  1 10:50:25 2004
@@ -1,4 +1,4 @@
-dnl $Id: config.m4,v 1.11 2004/07/18 12:03:51 wez Exp $
+dnl $Id: config.m4,v 1.12 2004/11/01 15:50:25 helly Exp $
 dnl config.m4 for extension SPL
 
 PHP_ARG_ENABLE(spl, enable SPL suppport,
@@ -9,6 +9,6 @@
     AC_MSG_ERROR(Cannot build SPL as a shared module)
   fi
   AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support]) 
-  PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c 
spl_array.c spl_directory.c spl_sxe.c, $ext_shared)
+  PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c 
spl_array.c spl_directory.c spl_sxe.c spl_exceptions.c, $ext_shared)
   PHP_ADD_EXTENSION_DEP(spl, simplexml)
 fi
http://cvs.php.net/diff.php/php-src/ext/spl/config.w32?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/spl/config.w32
diff -u php-src/ext/spl/config.w32:1.5 php-src/ext/spl/config.w32:1.6
--- php-src/ext/spl/config.w32:1.5      Tue Jan 20 14:49:21 2004
+++ php-src/ext/spl/config.w32  Mon Nov  1 10:50:25 2004
@@ -1,4 +1,4 @@
-// $Id: config.w32,v 1.5 2004/01/20 19:49:21 helly Exp $
+// $Id: config.w32,v 1.6 2004/11/01 15:50:25 helly Exp $
 // vim:ft=javascript
 
 ARG_ENABLE("spl", "SPL (Standard PHP Library) support", "yes");
@@ -7,6 +7,6 @@
        if (PHP_SPL_SHARED) {
                ERROR("SPL cannot be compiled as a shared ext");
        }
-       EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c 
spl_array.c spl_directory.c spl_sxe.c");
+       EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c 
spl_array.c spl_directory.c spl_sxe.c spl_exceptions.c");
        AC_DEFINE('HAVE_SPL', 1);
 }
http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.35&r2=1.36&ty=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.35 php-src/ext/spl/php_spl.c:1.36
--- php-src/ext/spl/php_spl.c:1.35      Mon Nov  1 05:45:53 2004
+++ php-src/ext/spl/php_spl.c   Mon Nov  1 10:50:25 2004
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_spl.c,v 1.35 2004/11/01 10:45:53 helly Exp $ */
+/* $Id: php_spl.c,v 1.36 2004/11/01 15:50:25 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
        #include "config.h"
@@ -32,6 +32,7 @@
 #include "spl_directory.h"
 #include "spl_iterators.h"
 #include "spl_sxe.h"
+#include "spl_exceptions.h"
 
 #ifdef COMPILE_DL_SPL
 ZEND_GET_MODULE(spl)
@@ -93,6 +94,7 @@
        PHP_MINIT(spl_array)(INIT_FUNC_ARGS_PASSTHRU);
        PHP_MINIT(spl_directory)(INIT_FUNC_ARGS_PASSTHRU);
        PHP_MINIT(spl_sxe)(INIT_FUNC_ARGS_PASSTHRU);
+       PHP_MINIT(spl_exceptions)(INIT_FUNC_ARGS_PASSTHRU);
 
        return SUCCESS;
 }
@@ -168,19 +170,29 @@
        SPL_ADD_CLASS(CachingRecursiveIterator, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(Countable, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(DirectoryIterator, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(DomainException, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(EmptyIterator, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(FilterIterator, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(InfiniteIterator, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(InvalidArgumentException, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(IteratorIterator, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(LengthException, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(LimitIterator, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(LogicException, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(NoRewindIterator, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(OuterIterator, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(OutOfRangeException, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(OutOfBoundsException, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(OverflowException, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(ParentIterator, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(RangeException, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(RecursiveDirectoryIterator, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(RecursiveIterator, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(RecursiveIteratorIterator, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(RuntimeException, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(SeekableIterator, z_list, sub, allow, ce_flags); \
        SPL_ADD_CLASS(SimpleXMLIterator, z_list, sub, allow, ce_flags); \
+       SPL_ADD_CLASS(UnderflowException, z_list, sub, allow, ce_flags); \
 
 /* {{{ spl_classes */
 PHP_FUNCTION(spl_classes)
http://cvs.php.net/diff.php/php-src/ext/spl/spl.php?r1=1.33&r2=1.34&ty=u
Index: php-src/ext/spl/spl.php
diff -u php-src/ext/spl/spl.php:1.33 php-src/ext/spl/spl.php:1.34
--- php-src/ext/spl/spl.php:1.33        Mon Nov  1 05:45:53 2004
+++ php-src/ext/spl/spl.php     Mon Nov  1 10:50:25 2004
@@ -13,26 +13,186 @@
  *
  * SPL - Standard PHP Library
  *
+ * SPL is a collection of interfaces and classes that are meant to solve 
+ * standard problems. 
+ *
+ * A nice article about it can be found 
+ * <a href="http://www.sitepoint.com/article/php5-standard-library/1";>here</a>.
+ *
  * You can download this documentation as a chm file 
  * <a href="http://php.net/~helly/php/ext/spl/spl.chm";>here</a>.
  *
  * (c) Marcus Boerger, 2003 - 2004
  */
 
-/** \defgroup SPL Internal classes
+/** @defgroup ZendEngine Zend engine classes
+ *
+ * The classes and interfaces in this group are contained in the c-code of 
+ * PHP's Zend engine.
+ */
+
+/** @defgroup SPL Internal classes
  *
  * The classes and interfaces in this group are contained in the c-code of 
  * ext/SPL.
  */
 
-/** \defgroup Examples Example classes
+/** @defgroup Examples Example classes
  *
  * The classes and interfaces in this group are contained as PHP code in the 
  * examples subdirectory of ext/SPL. Sooner or later they will be moved to
  * c-code.
  */
 
-/** \ingroup SPL
+/** @ingroup ZendEngine
+ * @brief Basic Exception class.
+ */
+class Exception
+{
+       /** The exception message */
+    protected $message;
+    
+    /** The string represenations as generated during construction */
+    private $string;
+    
+    /** The code passed to the constructor */
+    protected $code;
+    
+    /** The file name where the exception was instantiated */
+    protected $file;
+    
+    /** The line number where the exception was instantiated */
+    protected $line;
+    
+    /** The stack trace */
+    private $trace;
+
+       /** Prevent clone
+        */
+    final private function __clone();
+
+       /**
+        */
+       public function __construct($message, $code);
+
+       /** @return the message passed to the constructor
+        */
+    final public function getMessage();
+
+       /** @return the code passed to the constructor
+        */
+    final public function getCode();
+
+       /** @return the name of the file where the exception was thrown
+        */
+    final public function getFile();
+
+       /** @return the line number where the exception was thrown
+        */
+    final public function getLine();
+
+       /** @return the stack trace as array
+        */
+    final public function getTrace();
+
+       /** @return the stack trace as string
+        */
+    final public function getTraceAsString();
+
+       /** @return string represenation of exception
+        */
+    public function __toString();
+}
+
+/** @ingroup SPL
+ * @brief Exception that represents error in the program logic.
+ *
+ * This kind of exceptions should directly leed to a fix in your code.
+ */
+class LogicException extends Exception
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception that denotes a value not in the valid domain was used.
+ *
+ * This kind of exception should be used to inform about domain erors in 
+ * mathematical sense.
+ */
+class DomainException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception that denotes invalid arguments were passed.
+ */
+class InvalidArgumentException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown when a parameter exceeds the allowed length.
+ *
+ * This can be used for strings length, array size, file size, number of 
+ * elements read from an Iterator and so on.
+ */
+class LengthException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown when an illegal index was requested.
+ *
+ * This represents errors that should be detected at compile time.
+ *
+ * @see OutOfBoundsException
+ */
+class OutOfRangeException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown for errors that are only detectable at runtime. 
+ */
+class RuntimeException extends Exception
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown when an illegal index was requested.
+ *
+ * This represents errors that cannot be detected at compile time.
+ *
+ * @see OutOfRangeException
+ */
+class OutOfBoundsException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown to indicate arithmetic/buffer overflow.
+ */
+class OverflowException extends RuntimeException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown to indicate range errors during program execution.
+ *
+ * Normally this means there was an arithmetic error other than under/overflow.
+ */
+class RangeException extends RuntimeException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception Exception thrown to indicate arithmetic/buffer underflow.
+ */
+class UnderflowException extends RuntimeException
+{
+}
+
+/** \ingroup ZendEngine
  * \brief Interface to override array access of objects.
  */
 interface ArrayAccess
@@ -57,7 +217,7 @@
        function offsetExists($offset);
 }
 
-/** \ingroup SPL
+/** \ingroup ZendEngine
  * \brief Interface to detect a class is traversable using foreach.
  *
  * Abstract base interface that cannot be implemented alone. Instead it
@@ -75,7 +235,7 @@
 {
 }
 
-/** \ingroup SPL
+/** \ingroup ZendEngine
  * \brief Interface to create an external Iterator.
  *
  * \note This is an engine internal interface.
@@ -87,7 +247,7 @@
        function getIterator();
 }
 
-/** \ingroup SPL
+/** \ingroup ZendEngine
  * \brief Basic iterator
  *
  * Interface for external iterators or objects that can be iterated 

http://cvs.php.net/co.php/php-src/ext/spl/spl_exceptions.c?r=1.1&p=1
Index: php-src/ext/spl/spl_exceptions.c
+++ php-src/ext/spl/spl_exceptions.c
/*
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2004 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.0 of the PHP license,       |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.php.net/license/3_0.txt.                                  |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Authors: Marcus Boerger <[EMAIL PROTECTED]>                              |
   +----------------------------------------------------------------------+
 */

/* $Id: spl_exceptions.c,v 1.1 2004/11/01 15:50:25 helly Exp $ */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "zend_interfaces.h"
#include "zend_exceptions.h"

#include "php_spl.h"
#include "spl_functions.h"
#include "spl_engine.h"
#include "spl_exceptions.h"

zend_class_entry *spl_ce_LogicException;
zend_class_entry *spl_ce_DomainException;
zend_class_entry *spl_ce_InvalidArgumentException;
zend_class_entry *spl_ce_LengthException;
zend_class_entry *spl_ce_OutOfRangeException;
zend_class_entry *spl_ce_RuntimeException;
zend_class_entry *spl_ce_OutOfBoundsException;
zend_class_entry *spl_ce_OverflowException;
zend_class_entry *spl_ce_RangeException;
zend_class_entry *spl_ce_UnderflowException;

#define spl_ce_Exception zend_exception_get_default()

/* {{{ PHP_MINIT_FUNCTION(spl_exceptions) */
PHP_MINIT_FUNCTION(spl_exceptions)
{
    REGISTER_SPL_SUB_CLASS_EX(LogicException,           Exception,        NULL, NULL);
    REGISTER_SPL_SUB_CLASS_EX(DomainException,          LogicException,   NULL, NULL);
    REGISTER_SPL_SUB_CLASS_EX(InvalidArgumentException, LogicException,   NULL, NULL);
    REGISTER_SPL_SUB_CLASS_EX(LengthException,          LogicException,   NULL, NULL);
    REGISTER_SPL_SUB_CLASS_EX(OutOfRangeException,      LogicException,   NULL, NULL);

    REGISTER_SPL_SUB_CLASS_EX(RuntimeException,         Exception,        NULL, NULL);
    REGISTER_SPL_SUB_CLASS_EX(OutOfBoundsException      RuntimeException, NULL, NULL);
    REGISTER_SPL_SUB_CLASS_EX(OverflowException,        RuntimeException, NULL, NULL);
    REGISTER_SPL_SUB_CLASS_EX(RangeException,           RuntimeException, NULL, NULL);
    REGISTER_SPL_SUB_CLASS_EX(UnderflowException,       RuntimeException, NULL, NULL);

        return SUCCESS;
}
/* }}} */

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: fdm=marker
 * vim: noet sw=4 ts=4
 */

http://cvs.php.net/co.php/php-src/ext/spl/spl_exceptions.h?r=1.1&p=1
Index: php-src/ext/spl/spl_exceptions.h
+++ php-src/ext/spl/spl_exceptions.h
/*
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2004 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.0 of the PHP license,       |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.php.net/license/3_0.txt.                                  |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Authors: Marcus Boerger <[EMAIL PROTECTED]>                              |
   +----------------------------------------------------------------------+
 */

/* $Id: spl_exceptions.h,v 1.1 2004/11/01 15:50:25 helly Exp $ */

#ifndef SPL_EXCEPTIONS_H
#define SPL_EXCEPTIONS_H

#include "php.h"
#include "php_spl.h"

extern zend_class_entry *spl_ce_LogicException;
extern zend_class_entry *spl_ce_DomainException;
extern zend_class_entry *spl_ce_InvalidArgumentException;
extern zend_class_entry *spl_ce_LengthException;
extern zend_class_entry *spl_ce_OutOfRangeException;

extern zend_class_entry *spl_ce_RuntimeException;
extern zend_class_entry *spl_ce_OutOfBoundsException;
extern zend_class_entry *spl_ce_OverflowException;
extern zend_class_entry *spl_ce_RangeException;
extern zend_class_entry *spl_ce_UnderflowException;

PHP_MINIT_FUNCTION(spl_exceptions);

#endif /* SPL_EXCEPTIONS_H */

/*
 * Local Variables:
 * c-basic-offset: 4
 * tab-width: 4
 * End:
 * vim600: fdm=marker
 * vim: noet sw=4 ts=4
 */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to