Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for PHP7 #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions judy_arrayaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ PHP_METHOD(judy, offsetSet)
{
zval *offset, *value;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &offset, &value) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &offset, &value) == FAILURE) {
RETURN_FALSE;
}

if (judy_object_write_dimension_helper(getThis(), offset, value TSRMLS_CC) == SUCCESS) {
if (judy_object_write_dimension_helper(getThis(), offset, value) == SUCCESS) {
RETURN_TRUE;
}
RETURN_FALSE;
Expand All @@ -42,11 +42,11 @@ PHP_METHOD(judy, offsetUnset)
{
zval *offset;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &offset) == FAILURE) {
RETURN_FALSE;
}

if (judy_object_unset_dimension_helper(getThis(), offset TSRMLS_CC) == SUCCESS) {
if (judy_object_unset_dimension_helper(getThis(), offset) == SUCCESS) {
RETURN_TRUE;
}
RETURN_FALSE;
Expand All @@ -57,17 +57,17 @@ PHP_METHOD(judy, offsetUnset)
Fetch the given offset in the Judy Array */
PHP_METHOD(judy, offsetGet)
{
zval *offset, *result;
zval *offset, result, *result_ptr;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &offset) == FAILURE) {
RETURN_FALSE;
}

result = judy_object_read_dimension_helper(getThis(), offset TSRMLS_CC);
if (!result) {
result_ptr = judy_object_read_dimension_helper(getThis(), offset, &result);
if (!result_ptr) {
RETURN_FALSE;
}
RETURN_ZVAL(result, 1, 0);
RETURN_ZVAL(&result, 1, 0);
}
/* }}} */

Expand All @@ -77,11 +77,11 @@ PHP_METHOD(judy, offsetExists)
{
zval *offset;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &offset) == FAILURE) {
RETURN_FALSE;
}

if (judy_object_has_dimension_helper(getThis(), offset, 0 TSRMLS_CC)) {
if (judy_object_has_dimension_helper(getThis(), offset, 0)) {
RETURN_TRUE;
}
RETURN_FALSE;
Expand Down
41 changes: 24 additions & 17 deletions judy_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

/* {{{ judy_object_count
*/
int judy_object_count(zval *object, long *count TSRMLS_DC)
int judy_object_count(zval *object, long *count)
{
zval *rv;
zval rv;

/* calling the object's count() method */
zend_call_method_with_0_params(&object, NULL, NULL, "count", &rv);
*count = Z_LVAL_P(rv);
zend_call_method_with_0_params(object, NULL, NULL, "count", &rv);
*count = Z_LVAL_P(&rv);

/* destruct the zval returned value */
zval_ptr_dtor(&rv);
Expand All @@ -38,16 +38,17 @@ int judy_object_count(zval *object, long *count TSRMLS_DC)

/* {{{ judy_object_clone
*/
zend_object_value judy_object_clone(zval *this_ptr TSRMLS_DC)
zend_object *judy_object_clone(zval *this_ptr)
{
judy_object *new_obj = NULL;
judy_object *old_obj = (judy_object *) zend_object_store_get_object(this_ptr TSRMLS_CC);
zend_object_value new_ov = judy_object_new_ex(old_obj->std.ce, &new_obj TSRMLS_CC);
judy_object *old_obj = php_judy_object(Z_OBJ_P(this_ptr));

judy_object_new_ex(old_obj->std.ce, &new_obj);

/* new Judy array to populate */
Pvoid_t newJArray = (Pvoid_t) NULL;

zend_objects_clone_members(&new_obj->std, new_ov, &old_obj->std, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
zend_objects_clone_members(&new_obj->std, &old_obj->std);

if (old_obj->type == TYPE_BITSET) {
/* Cloning Judy1 Array */
Expand All @@ -71,19 +72,22 @@ zend_object_value judy_object_clone(zval *this_ptr TSRMLS_DC)
Word_t kindex = 0;

/* Pointer to the old value */
Word_t *PValue;
Pvoid_t *PValue;

/* Pointer to the new value */
Word_t *newPValue;
Pvoid_t *newPValue;

JLF(PValue, old_obj->array, kindex);
while(PValue != NULL && PValue != PJERR)
{
JLI(newPValue, newJArray, kindex);
if (newPValue != NULL && newPValue != PJERR) {
*newPValue = *PValue;
if (old_obj->type == TYPE_INT_TO_MIXED)
Z_ADDREF_P(*(zval **)PValue);
if (old_obj->type == TYPE_INT_TO_MIXED) {
zval *value = ecalloc(1, sizeof(zval));
ZVAL_DUP(value, *(zval **)PValue);
*newPValue = value;
}
}
JLN(PValue, old_obj->array, kindex)
}
Expand All @@ -94,10 +98,10 @@ zend_object_value judy_object_clone(zval *this_ptr TSRMLS_DC)
uint8_t kindex[PHP_JUDY_MAX_LENGTH];

/* Pointer to the old value */
Word_t *PValue;
Pvoid_t *PValue;

/* Pointer to the new value */
Word_t *newPValue;
Pvoid_t *newPValue;

/* smallest string is a null-terminated character */
kindex[0] = '\0';
Expand All @@ -108,8 +112,11 @@ zend_object_value judy_object_clone(zval *this_ptr TSRMLS_DC)
JSLI(newPValue, newJArray, kindex);
if (newPValue != NULL && newPValue != PJERR) {
*newPValue = *PValue;
if (old_obj->type == TYPE_STRING_TO_MIXED)
Z_ADDREF_P(*(zval **)PValue);
if (old_obj->type == TYPE_STRING_TO_MIXED) {
zval *value = ecalloc(1, sizeof(zval));
ZVAL_DUP(value, *(zval **)PValue);
*newPValue = value;
}
}
JSLN(PValue, old_obj->array, kindex)
}
Expand All @@ -118,7 +125,7 @@ zend_object_value judy_object_clone(zval *this_ptr TSRMLS_DC)
new_obj->array = newJArray;
new_obj->type = old_obj->type;

return new_ov;
return &new_obj->std;
}
/* }}} */

Expand Down
4 changes: 2 additions & 2 deletions judy_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "zend_exceptions.h"
#include "zend_interfaces.h"

zend_object_value judy_object_clone(zval *this_ptr TSRMLS_DC);
int judy_object_count(zval *object, long *count TSRMLS_DC);
zend_object *judy_object_clone(zval *this_ptr);
int judy_object_count(zval *object, long *count);

#endif /* JUDY_HANDLERS_H */

Expand Down
Loading