summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-06-04 20:54:48 +0000
committerMarcus Boerger <helly@php.net>2003-06-04 20:54:48 +0000
commitb70cf4074252a2e524ead2927c8e29ecb2eaa25e (patch)
treed764afe2e6f8b0b2cfef5e833f8b26edb984e76e /ext/spl
parenta8c7c3bc5e93a0de0639bd25965a15375db0d04b (diff)
downloadphp-git-b70cf4074252a2e524ead2927c8e29ecb2eaa25e.tar.gz
Goodbye namespaces
Diffstat (limited to 'ext/spl')
-rwxr-xr-xext/spl/php_spl.c22
-rwxr-xr-xext/spl/php_spl.h1
-rwxr-xr-xext/spl/spl_engine.c2
-rwxr-xr-xext/spl/spl_functions.c29
-rwxr-xr-xext/spl/spl_functions.h15
-rwxr-xr-xext/spl/tests/array_access_001.phpt4
-rwxr-xr-xext/spl/tests/array_access_002.phpt4
-rwxr-xr-xext/spl/tests/array_access_ex.phpt10
-rwxr-xr-xext/spl/tests/array_read.phpt4
-rwxr-xr-xext/spl/tests/foreach.phpt4
-rwxr-xr-xext/spl/tests/foreach_break.phpt4
-rwxr-xr-xext/spl/tests/forward.phpt10
-rwxr-xr-xext/spl/tests/sequence.phpt16
13 files changed, 56 insertions, 69 deletions
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index 4467b0aa60..00b1a37f0c 100755
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -62,7 +62,6 @@ zend_module_entry spl_module_entry = {
};
/* }}} */
-zend_namespace *spl_ns_spl;
zend_class_entry *spl_ce_iterator;
zend_class_entry *spl_ce_forward;
zend_class_entry *spl_ce_assoc;
@@ -123,8 +122,6 @@ PHP_MINIT_FUNCTION(spl)
{
ZEND_INIT_MODULE_GLOBALS(spl, spl_init_globals, NULL);
- REGISTER_SPL_NAMESPACE(spl);
-
REGISTER_SPL_INTERFACE(spl, iterator);
REGISTER_SPL_INTF_FUNC(spl, iterator, new_iterator);
@@ -294,11 +291,28 @@ PHP_FUNCTION(class_implements)
}
/* }}} */
+#define SPL_ADD_CLASS(class_name) \
+ spl_add_classes(&spl_ce_ ## class_name, return_value TSRMLS_CC)
+
/* {{{ spl_classes */
PHP_FUNCTION(spl_classes)
{
array_init(return_value);
- zend_hash_apply_with_argument(&spl_ns_spl->class_table, (apply_func_arg_t)spl_add_classes, return_value TSRMLS_CC);
+
+ SPL_ADD_CLASS(iterator);
+ SPL_ADD_CLASS(forward);
+ SPL_ADD_CLASS(sequence);
+ SPL_ADD_CLASS(assoc);
+ SPL_ADD_CLASS(forward_assoc);
+ SPL_ADD_CLASS(sequence_assoc);
+ SPL_ADD_CLASS(array_read);
+ SPL_ADD_CLASS(array_access);
+ SPL_ADD_CLASS(array_access_ex);
+ SPL_ADD_CLASS(array_writer);
+
+#ifdef SPL_ARRAY_WRITE
+ SPL_ADD_CLASS(array_writer_default);
+#endif
}
/* }}} */
diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h
index d06090d52d..e54ef2dbcb 100755
--- a/ext/spl/php_spl.h
+++ b/ext/spl/php_spl.h
@@ -83,7 +83,6 @@ extern int spl_globals_id;
extern zend_spl_globals spl_globals;
#endif
-extern zend_namespace *spl_ns_spl;
extern zend_class_entry *spl_ce_iterator;
extern zend_class_entry *spl_ce_forward;
extern zend_class_entry *spl_ce_sequence;
diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c
index 1f4bb78f47..30cee2fd57 100755
--- a/ext/spl/spl_engine.c
+++ b/ext/spl/spl_engine.c
@@ -186,7 +186,6 @@ int spl_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **
zend_class_entry *current_scope;
zend_class_entry *calling_scope = NULL;
zval *current_this;
- zend_namespace *current_namespace = EG(active_namespace);
zend_execute_data execute_data;
va_list args;
@@ -315,7 +314,6 @@ int spl_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **
}
zend_ptr_stack_clear_multiple(TSRMLS_C);
EG(function_state_ptr) = original_function_state_ptr;
- EG(active_namespace) = current_namespace;
if (EG(This)) {
zval_ptr_dtor(&EG(This));
diff --git a/ext/spl/spl_functions.c b/ext/spl/spl_functions.c
index ea51d695e2..eefa130d7f 100755
--- a/ext/spl/spl_functions.c
+++ b/ext/spl/spl_functions.c
@@ -34,25 +34,14 @@ void spl_destroy_class(zend_class_entry ** ppce)
}
/* }}} */
-/* {{{ spl_register_namespace */
-void spl_register_namespace(zend_namespace ** ppns, char * namespace_name TSRMLS_DC)
-{
- zend_namespace ns;
-
- INIT_NAMESPACE(ns, namespace_name);
- ns.name_length = strlen(namespace_name);
- *ppns = zend_register_internal_namespace(&ns TSRMLS_CC);
-}
-/* }}} */
-
/* {{{ spl_register_interface */
-void spl_register_interface(zend_class_entry ** ppce, zend_namespace * namespace_entry, char * class_name TSRMLS_DC)
+void spl_register_interface(zend_class_entry ** ppce, char * class_name TSRMLS_DC)
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, class_name, NULL);
ce.name_length = strlen(class_name);
- *ppce = zend_register_internal_ns_class(&ce, NULL, namespace_entry, NULL TSRMLS_CC);
+ *ppce = zend_register_internal_class(&ce TSRMLS_CC);
/* entries changed by initialize */
(*ppce)->ce_flags = ZEND_ACC_ABSTRACT | ZEND_ACC_INTERFACE;
@@ -60,14 +49,14 @@ void spl_register_interface(zend_class_entry ** ppce, zend_namespace * namespace
/* }}} */
/* {{{ spl_register_std_class */
-void spl_register_std_class(zend_class_entry ** ppce, zend_namespace * namespace_entry, char * class_name, void * obj_ctor TSRMLS_DC)
+void spl_register_std_class(zend_class_entry ** ppce, char * class_name, void * obj_ctor TSRMLS_DC)
{
zend_class_entry ce;
memset(&ce, 0, sizeof(zend_class_entry));
INIT_CLASS_ENTRY(ce, class_name, NULL);
ce.name_length = strlen(class_name);
- *ppce = zend_register_internal_ns_class(&ce, NULL, namespace_entry, NULL TSRMLS_CC);
+ *ppce = zend_register_internal_class(&ce TSRMLS_CC);
/* entries changed by initialize */
(*ppce)->create_object = obj_ctor;
@@ -86,7 +75,6 @@ void spl_register_interface_function(zend_class_entry * class_entry, char * fn_n
pfunction->function_name = fn_name;
pfunction->scope = class_entry;
pfunction->fn_flags = ZEND_ACC_ABSTRACT | ZEND_ACC_PUBLIC;
- pfunction->ns = class_entry->ns;
pfunction->prototype = NULL;
zend_hash_add(&class_entry->function_table, fn_name, strlen(fn_name)+1, &function, sizeof(zend_function), (void**)&reg_function);
}
@@ -118,14 +106,7 @@ void spl_register_functions(zend_class_entry * class_entry, function_entry * fun
/* {{ spl_make_fully_qualyfied_name */
char * spl_make_fully_qualyfied_name(zend_class_entry * pce TSRMLS_DC)
{
- if (pce->ns && (pce->ns != &CG(global_namespace))) {
- char *retval;
-
- spprintf(&retval, 0, "%s::%s", pce->ns->name, pce->name);
- return retval;
- } else {
- return estrdup(pce->name);
- }
+ return estrdup(pce->name);
}
/* }}} */
diff --git a/ext/spl/spl_functions.h b/ext/spl/spl_functions.h
index f6a7b57ab4..a68ffacede 100755
--- a/ext/spl/spl_functions.h
+++ b/ext/spl/spl_functions.h
@@ -23,14 +23,11 @@
typedef zend_object_value (*create_object_func_t)(zend_class_entry *class_type TSRMLS_DC);
-#define REGISTER_SPL_NAMESPACE(namespace_name) \
- spl_register_namespace(&spl_ns_ ## namespace_name, # namespace_name TSRMLS_CC);
-
#define REGISTER_SPL_STD_CLASS(namespace_name, class_name, obj_ctor) \
- spl_register_std_class(&spl_ce_ ## class_name, spl_ns_ ## namespace_name, # class_name, obj_ctor TSRMLS_CC);
+ spl_register_std_class(&spl_ce_ ## class_name, "spl_" # class_name, obj_ctor TSRMLS_CC);
#define REGISTER_SPL_INTERFACE(namespace_name, class_name) \
- spl_register_interface(&spl_ce_ ## class_name, spl_ns_ ## namespace_name, # class_name TSRMLS_CC);
+ spl_register_interface(&spl_ce_ ## class_name, "spl_" # class_name TSRMLS_CC);
#define REGISTER_SPL_INTF_FUNC(namespace_name, class_name, function_name) \
spl_register_interface_function(spl_ce_ ## class_name, # function_name TSRMLS_CC);
@@ -46,11 +43,9 @@ typedef zend_object_value (*create_object_func_t)(zend_class_entry *class_type T
void spl_destroy_class(zend_class_entry ** ppce);
-void spl_register_namespace(zend_namespace ** ppns, char * namespace_name TSRMLS_DC);
-
-void spl_register_std_class(zend_class_entry ** ppce, zend_namespace * namespace_entry, char * class_name, create_object_func_t ctor TSRMLS_DC);
+void spl_register_std_class(zend_class_entry ** ppce, char * class_name, create_object_func_t ctor TSRMLS_DC);
-void spl_register_interface(zend_class_entry ** ppce, zend_namespace * namespace_entry, char * class_name TSRMLS_DC);
+void spl_register_interface(zend_class_entry ** ppce, char * class_name TSRMLS_DC);
void spl_register_interface_function(zend_class_entry * class_entry, char * fn_name TSRMLS_DC);
void spl_register_parent_ce(zend_class_entry * class_entry, zend_class_entry * parent_class TSRMLS_DC);
@@ -59,7 +54,7 @@ void spl_register_functions(zend_class_entry * class_entry, function_entry * fun
char * spl_make_fully_qualyfied_name(zend_class_entry * pce TSRMLS_DC);
void spl_add_class_name(zval * list, zend_class_entry * pce TSRMLS_DC);
-void spl_add_interfaces(zval *list, zend_class_entry * pce TSRMLS_DC);
+void spl_add_interfaces(zval * list, zend_class_entry * pce TSRMLS_DC);
int spl_add_classes(zend_class_entry ** ppce, zval *list TSRMLS_DC);
#define SPL_CLASS_FE(class_name, function_name, arg_types) \
diff --git a/ext/spl/tests/array_access_001.phpt b/ext/spl/tests/array_access_001.phpt
index 5748a5c594..12b70e4c31 100755
--- a/ext/spl/tests/array_access_001.phpt
+++ b/ext/spl/tests/array_access_001.phpt
@@ -3,11 +3,11 @@ SPL: array_access
--SKIPIF--
<?php
if (!extension_loaded("spl")) die("skip");
- if (!in_array("spl::array_access",spl_classes())) die("skip spl::array_access not present");
+ if (!in_array("spl_array_access", spl_classes())) die("skip spl_array_access not present");
?>
--FILE--
<?php
-class c implements spl::array_access {
+class c implements spl_array_access {
public $a = array('1st', 1, 2=>'3rd', '4th'=>4);
function exists($index) {
diff --git a/ext/spl/tests/array_access_002.phpt b/ext/spl/tests/array_access_002.phpt
index d415b19248..64dccb3acb 100755
--- a/ext/spl/tests/array_access_002.phpt
+++ b/ext/spl/tests/array_access_002.phpt
@@ -3,11 +3,11 @@ SPL: array_access without return in set()
--SKIPIF--
<?php
if (!extension_loaded("spl")) die("skip");
- if (!in_array("spl::array_access",spl_classes())) die("skip spl::array_access not present");
+ if (!in_array("spl_array_access", spl_classes())) die("skip spl_array_access not present");
?>
--FILE--
<?php
-class c implements spl::array_access {
+class c implements spl_array_access {
public $a = array('1st', 1, 2=>'3rd', '4th'=>4);
function exists($index) {
diff --git a/ext/spl/tests/array_access_ex.phpt b/ext/spl/tests/array_access_ex.phpt
index 2800c0508e..ed7aceab19 100755
--- a/ext/spl/tests/array_access_ex.phpt
+++ b/ext/spl/tests/array_access_ex.phpt
@@ -3,11 +3,11 @@ SPL: array_access
--SKIPIF--
<?php
if (!extension_loaded("spl")) die("skip");
- if (!in_array("spl::array_access",spl_classes())) die("skip spl::array_access not present");
+ if (!in_array("spl_array_access", spl_classes())) die("skip spl_array_access not present");
?>
--FILE--
<?php
-class array_write implements spl::array_writer {
+class array_write implements spl_array_writer {
private $obj;
private $idx;
@@ -22,7 +22,7 @@ class array_write implements spl::array_writer {
}
}
-class c implements spl::array_access_ex {
+class c implements spl_array_access_ex {
public $a = array('1st', 1, 2=>'3rd', '4th'=>4);
@@ -104,11 +104,11 @@ c::get(4th)
int(4)
c::exists(5th)
-Notice: Undefined index: 5th in /usr/src/php5/ext/spl/tests/array_access_ex.php on line 49
+Notice: Undefined index: 5th in %sarray_access_ex.php on line %d
NULL
c::exists(6)
-Notice: Undefined index: 6 in /usr/src/php5/ext/spl/tests/array_access_ex.php on line 50
+Notice: Undefined index: 6 in %sarray_access_ex.php on line %d
NULL
WRITE 1
c::exists(1)
diff --git a/ext/spl/tests/array_read.phpt b/ext/spl/tests/array_read.phpt
index b1e95fd6a1..032373d52d 100755
--- a/ext/spl/tests/array_read.phpt
+++ b/ext/spl/tests/array_read.phpt
@@ -10,7 +10,7 @@ echo "EXTERNAL\n";
$a = array('1st', 1, 2=>'3rd', '4th'=>4);
var_dump($a);
-class external implements spl::array_read {
+class external implements spl_array_read {
function exists($index) {
echo __METHOD__ . "($index)\n";
@@ -46,7 +46,7 @@ $out = $obj['4th']; echo "$out\n";
echo "INTERNAL\n";
-class internal implements spl::array_read {
+class internal implements spl_array_read {
public $a = array('1st', 1, 2=>'3rd', '4th'=>4);
diff --git a/ext/spl/tests/foreach.phpt b/ext/spl/tests/foreach.phpt
index f3c902e74f..de05f4b3f5 100755
--- a/ext/spl/tests/foreach.phpt
+++ b/ext/spl/tests/foreach.phpt
@@ -4,7 +4,7 @@ SPL: foreach and iterator
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
-class c_iter implements spl::forward_assoc {
+class c_iter implements spl_forward_assoc {
private $obj;
private $num = 0;
@@ -36,7 +36,7 @@ class c_iter implements spl::forward_assoc {
}
}
-class c implements spl::iterator {
+class c implements spl_iterator {
public $max = 3;
diff --git a/ext/spl/tests/foreach_break.phpt b/ext/spl/tests/foreach_break.phpt
index 606682d73c..b17831c74c 100755
--- a/ext/spl/tests/foreach_break.phpt
+++ b/ext/spl/tests/foreach_break.phpt
@@ -4,7 +4,7 @@ SPL: foreach and break
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
-class c_iter implements spl::forward_assoc {
+class c_iter implements spl_forward_assoc {
private $obj;
private $num = 0;
@@ -36,7 +36,7 @@ class c_iter implements spl::forward_assoc {
}
}
-class c implements spl::iterator {
+class c implements spl_iterator {
public $max = 3;
diff --git a/ext/spl/tests/forward.phpt b/ext/spl/tests/forward.phpt
index 3421593268..574d87e628 100755
--- a/ext/spl/tests/forward.phpt
+++ b/ext/spl/tests/forward.phpt
@@ -4,7 +4,7 @@ SPL: forward
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
-class c implements spl::forward_assoc {
+class c implements spl_forward_assoc {
public $max = 3;
public $num = 0;
@@ -36,7 +36,7 @@ $i = new c();
$c_info = array(class_name($i) => array('inheits' => class_parents($i), 'implements' => class_implements($i)));
print_r($c_info);
-$methods = get_class_methods("spl::forward_assoc");
+$methods = get_class_methods("spl_forward_assoc");
sort($methods);
print_r($methods);
$methods = get_class_methods($i);
@@ -75,9 +75,9 @@ Array
[implements] => Array
(
- [spl::forward_assoc] => spl::forward_assoc
- [spl::assoc] => spl::assoc
- [spl::forward] => spl::forward
+ [spl_forward_assoc] => spl_forward_assoc
+ [spl_assoc] => spl_assoc
+ [spl_forward] => spl_forward
)
)
diff --git a/ext/spl/tests/sequence.phpt b/ext/spl/tests/sequence.phpt
index 3c6ef2a234..d5408bb75f 100755
--- a/ext/spl/tests/sequence.phpt
+++ b/ext/spl/tests/sequence.phpt
@@ -4,7 +4,7 @@ SPL: sequence
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
-class c implements spl::iterator {
+class c implements spl_iterator {
public $max = 3;
@@ -14,7 +14,7 @@ class c implements spl::iterator {
}
}
-class c_iter implements spl::sequence_assoc {
+class c_iter implements spl_sequence_assoc {
private $obj;
private $num = 0;
@@ -78,7 +78,7 @@ Array
[implements] => Array
(
- [spl::iterator] => spl::iterator
+ [spl_iterator] => spl_iterator
)
)
@@ -91,11 +91,11 @@ Array
[implements] => Array
(
- [spl::sequence_assoc] => spl::sequence_assoc
- [spl::forward_assoc] => spl::forward_assoc
- [spl::assoc] => spl::assoc
- [spl::forward] => spl::forward
- [spl::sequence] => spl::sequence
+ [spl_sequence_assoc] => spl_sequence_assoc
+ [spl_forward_assoc] => spl_forward_assoc
+ [spl_assoc] => spl_assoc
+ [spl_forward] => spl_forward
+ [spl_sequence] => spl_sequence
)
)