Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 135 lines (110 sloc) 4.439 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
/*
+----------------------------------------------------------------------+
| PHP Judy |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 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_01.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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Nicolas Brousse <nicolas@brousse.info> |
+----------------------------------------------------------------------+
*/

#ifndef PHP_JUDY_H
#define PHP_JUDY_H

#define PHP_JUDY_VERSION "1.0.2"
#define PHP_JUDY_EXTNAME "judy"

#include <Judy.h>

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

extern zend_module_entry judy_module_entry;
#define phpext_judy_ptr &judy_module_entry

#ifdef PHP_WIN32
# define PHP_JUDY_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_JUDY_API __attribute__ ((visibility("default")))
#else
# define PHP_JUDY_API
#endif

#ifdef ZTS
#include "TSRM.h"
#endif

extern const zend_function_entry judy_class_methods[];

/* {{{ judy_type
internal Judy Array type (aka Judy1, JudyL and JudySL) */
typedef enum _judy_type {
    TYPE_BITSET=1,
    TYPE_INT_TO_INT,
    TYPE_INT_TO_MIXED,
    TYPE_STRING_TO_INT,
    TYPE_STRING_TO_MIXED
} judy_type;
/* }}} */

#define JTYPE(jtype, type) { \
if (type != TYPE_BITSET && type != TYPE_INT_TO_INT \
&& type != TYPE_INT_TO_MIXED \
&& type != TYPE_STRING_TO_INT \
&& type != TYPE_STRING_TO_MIXED) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not a valid Judy type. Please check the documentation for valid Judy type constant."); \
} \
jtype = type; \
}

#define JUDY_METHOD_ERROR_HANDLING \
zend_error_handling error_handling; \
zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);

#define JUDY_METHOD_GET_OBJECT \
zval *object = getThis(); \
judy_object *intern = (judy_object *) zend_object_store_get_object(object TSRMLS_CC);

typedef struct _judy_object {
zend_object std;
long type;
Pvoid_t array;
unsigned long counter;
Word_t next_empty;
zend_bool next_empty_is_valid;
} judy_object;

/* Max length, this must be a constant for it to work in
* declarings as we cannot use runtime decided values at
* compile time ofcourse
*
* TODO: This needs to be handled better
*/
#define PHP_JUDY_MAX_LENGTH 65536

zend_object_value judy_object_new(zend_class_entry *ce TSRMLS_DC);
zend_object_value judy_object_new_ex(zend_class_entry *ce, judy_object **ptr TSRMLS_DC);

zval *judy_object_read_dimension_helper(zval *object, zval *offset TSRMLS_DC);
int judy_object_write_dimension_helper(zval *object, zval *offset, zval *value TSRMLS_DC);
int judy_object_has_dimension_helper(zval *object, zval *offset, int check_empty TSRMLS_DC);
int judy_object_unset_dimension_helper(zval *object, zval *offset TSRMLS_DC);

/* {{{ REGISTER_JUDY_CLASS_CONST_LONG */
#define REGISTER_JUDY_CLASS_CONST_LONG(const_name, value) \
zend_declare_class_constant_long(judy_ce, const_name, sizeof(const_name)-1, (long) value TSRMLS_CC);
/* }}} */

ZEND_BEGIN_MODULE_GLOBALS(judy)
    unsigned long max_length;
ZEND_END_MODULE_GLOBALS(judy)

ZEND_EXTERN_MODULE_GLOBALS(judy)

#ifdef ZTS
#define JUDY_G(v) TSRMG(judy_globals_id, zend_judy_globals *, v)
#else
#define JUDY_G(v) (judy_globals.v)
#endif

/* Grabbing CE's so that other exts can use the date objects too */
PHP_JUDY_API zend_class_entry *php_judy_ce(void);

#endif /* PHP_JUDY_H */


/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
Something went wrong with that request. Please try again.