closes #1
This commit is contained in:
parent
3bf72f95e7
commit
db0465e943
|
@ -12,7 +12,6 @@ Method names and functionalities are inspired by [Kotlin.Collections](https://ko
|
||||||
### 1.1 Notes
|
### 1.1 Notes
|
||||||
|
|
||||||
* Requires PHP 7.1 and above.
|
* Requires PHP 7.1 and above.
|
||||||
* Currently not working on MacOS. Fix in progress.
|
|
||||||
|
|
||||||
## 2. Documentation
|
## 2. Documentation
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "php_collections.h"
|
#include "php_collections.h"
|
||||||
|
|
||||||
zend_object_handlers* collection_handlers;
|
zend_object_handlers collection_handlers;
|
||||||
|
|
||||||
zend_class_entry* collections_collection_ce;
|
zend_class_entry* collections_collection_ce;
|
||||||
zend_class_entry* collections_pair_ce;
|
zend_class_entry* collections_pair_ce;
|
||||||
|
@ -36,13 +36,12 @@ PHP_MINIT_FUNCTION(collections)
|
||||||
2, zend_ce_countable,
|
2, zend_ce_countable,
|
||||||
#endif
|
#endif
|
||||||
zend_ce_arrayaccess);
|
zend_ce_arrayaccess);
|
||||||
collection_handlers = (zend_object_handlers*)emalloc(sizeof(zend_object_handlers));
|
memcpy(&collection_handlers, &std_object_handlers, sizeof(zend_object_handlers));
|
||||||
memcpy(collection_handlers, &std_object_handlers, sizeof(zend_object_handlers));
|
collection_handlers.count_elements = count_collection;
|
||||||
collection_handlers->count_elements = count_collection;
|
collection_handlers.unset_dimension = collection_offset_unset;
|
||||||
collection_handlers->unset_dimension = collection_offset_unset;
|
collection_handlers.write_dimension = collection_offset_set;
|
||||||
collection_handlers->write_dimension = collection_offset_set;
|
collection_handlers.read_dimension = collection_offset_get;
|
||||||
collection_handlers->read_dimension = collection_offset_get;
|
collection_handlers.has_dimension = collection_offset_exists;
|
||||||
collection_handlers->has_dimension = collection_offset_exists;
|
|
||||||
zend_class_entry pair_ce;
|
zend_class_entry pair_ce;
|
||||||
INIT_CLASS_ENTRY_EX(pair_ce, "Pair", sizeof "Pair" - 1, pair_methods);
|
INIT_CLASS_ENTRY_EX(pair_ce, "Pair", sizeof "Pair" - 1, pair_methods);
|
||||||
collections_pair_ce = zend_register_internal_class(&pair_ce);
|
collections_pair_ce = zend_register_internal_class(&pair_ce);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
zend_object_std_init(name, ce); \
|
zend_object_std_init(name, ce); \
|
||||||
(name)->handlers = object_handlers
|
(name)->handlers = object_handlers
|
||||||
#define NEW_COLLECTION_OBJ(name) \
|
#define NEW_COLLECTION_OBJ(name) \
|
||||||
NEW_OBJ(name, collections_collection_ce, collection_handlers)
|
NEW_OBJ(name, collections_collection_ce, &collection_handlers)
|
||||||
#define NEW_PAIR_OBJ(name) \
|
#define NEW_PAIR_OBJ(name) \
|
||||||
NEW_OBJ(name, collections_pair_ce, &std_object_handlers); \
|
NEW_OBJ(name, collections_pair_ce, &std_object_handlers); \
|
||||||
name->properties = (zend_array*)emalloc(sizeof(zend_array)); \
|
name->properties = (zend_array*)emalloc(sizeof(zend_array)); \
|
||||||
|
|
|
@ -31,7 +31,7 @@ extern PHP_COLLECTIONS_API zend_class_entry* collections_pair_ce;
|
||||||
extern zend_string* collections_pair_first;
|
extern zend_string* collections_pair_first;
|
||||||
extern zend_string* collections_pair_second;
|
extern zend_string* collections_pair_second;
|
||||||
|
|
||||||
extern zend_object_handlers* collection_handlers;
|
extern zend_object_handlers collection_handlers;
|
||||||
|
|
||||||
int count_collection(zval* obj, zend_long* count);
|
int count_collection(zval* obj, zend_long* count);
|
||||||
int collection_offset_exists(zval* object, zval* offset, int check_empty);
|
int collection_offset_exists(zval* object, zval* offset, int check_empty);
|
||||||
|
|
Reference in New Issue