Permalink
Browse files

- MFH: Constness (Added const qualifier to several function parameters)

  • Loading branch information...
1 parent 0537607 commit cf7384aa4015de9dd21a958146933bbf1f13f0a9 @felipensp felipensp committed Aug 12, 2008
View
@@ -63,7 +63,7 @@ ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRML
void (*zend_on_timeout)(int seconds TSRMLS_DC);
static void (*zend_message_dispatcher_p)(long message, void *data);
-static int (*zend_get_configuration_directive_p)(char *name, uint name_length, zval *contents);
+static int (*zend_get_configuration_directive_p)(const char *name, uint name_length, zval *contents);
static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
{
@@ -803,7 +803,7 @@ void zend_set_utility_values(zend_utility_values *utility_values) /* {{{ */
/* }}} */
/* this should be compatible with the standard zenderror */
-void zenderror(char *error) /* {{{ */
+void zenderror(const char *error) /* {{{ */
{
zend_error(E_PARSE, "%s", error);
}
@@ -826,7 +826,7 @@ ZEND_API void _zend_bailout(char *filename, uint lineno) /* {{{ */
/* }}} */
END_EXTERN_C()
-void zend_append_version_info(zend_extension *extension) /* {{{ */
+void zend_append_version_info(const zend_extension *extension) /* {{{ */
{
char *new_info;
uint new_info_length;
@@ -958,7 +958,7 @@ ZEND_API void zend_message_dispatcher(long message, void *data) /* {{{ */
/* }}} */
END_EXTERN_C()
-ZEND_API int zend_get_configuration_directive(char *name, uint name_length, zval *contents) /* {{{ */
+ZEND_API int zend_get_configuration_directive(const char *name, uint name_length, zval *contents) /* {{{ */
{
if (zend_get_configuration_directive_p) {
return zend_get_configuration_directive_p(name, name_length, contents);
@@ -1148,7 +1148,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn));
#endif
-ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...) /* {{{ */
+ZEND_API void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) /* {{{ */
{
#if ZEND_DEBUG
va_list args;
@@ -1245,7 +1245,7 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
#define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d) : %s"
-ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC) /* {{{ */
+ZEND_API char *zend_make_compiled_string_description(const char *name TSRMLS_DC) /* {{{ */
{
char *cur_filename;
int cur_lineno;
View
@@ -473,7 +473,7 @@ typedef struct _zend_utility_functions {
void (*message_handler)(long message, void *data);
void (*block_interruptions)(void);
void (*unblock_interruptions)(void);
- int (*get_configuration_directive)(char *name, uint name_length, zval *contents);
+ int (*get_configuration_directive)(const char *name, uint name_length, zval *contents);
void (*ticks_function)(int ticks);
void (*on_timeout)(int seconds TSRMLS_DC);
int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
@@ -572,7 +572,7 @@ ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int in
ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC);
ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC);
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
-ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
+ZEND_API void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
END_EXTERN_C()
void zend_activate(TSRMLS_D);
@@ -623,7 +623,7 @@ extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_le
ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
-void zenderror(char *error);
+void zenderror(const char *error);
/* The following #define is used for code duality in PHP for Engine 1 & 2 */
#define ZEND_STANDARD_CLASS_DEF_PTR zend_standard_class_def
@@ -641,7 +641,7 @@ END_EXTERN_C()
BEGIN_EXTERN_C()
ZEND_API void zend_message_dispatcher(long message, void *data);
-ZEND_API int zend_get_configuration_directive(char *name, uint name_length, zval *contents);
+ZEND_API int zend_get_configuration_directive(const char *name, uint name_length, zval *contents);
END_EXTERN_C()
/* Messages for applications of Zend */
View
@@ -219,13 +219,13 @@ ZEND_API char *zend_get_type_by_const(int type) /* {{{ */
}
/* }}} */
-ZEND_API char *zend_zval_type_name(zval *arg) /* {{{ */
+ZEND_API char *zend_zval_type_name(const zval *arg) /* {{{ */
{
return zend_get_type_by_const(Z_TYPE_P(arg));
}
/* }}} */
-ZEND_API zend_class_entry *zend_get_class_entry(zval *zobject TSRMLS_DC) /* {{{ */
+ZEND_API zend_class_entry *zend_get_class_entry(const zval *zobject TSRMLS_DC) /* {{{ */
{
if (Z_OBJ_HT_P(zobject)->get_class_entry) {
return Z_OBJ_HT_P(zobject)->get_class_entry(zobject TSRMLS_CC);
@@ -237,7 +237,7 @@ ZEND_API zend_class_entry *zend_get_class_entry(zval *zobject TSRMLS_DC) /* {{{
/* }}} */
/* returns 1 if you need to copy result, 0 if it's already a copy */
-ZEND_API int zend_get_object_classname(zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC) /* {{{ */
+ZEND_API int zend_get_object_classname(const zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC) /* {{{ */
{
if (Z_OBJ_HT_P(object)->get_class_name == NULL ||
Z_OBJ_HT_P(object)->get_class_name(object, class_name, class_name_len, 0 TSRMLS_CC) != SUCCESS) {
@@ -291,7 +291,7 @@ static int parse_arg_object_to_string(zval **arg, char **p, int *pl, int type TS
}
/* }}} */
-static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **spec, char **error, int *severity TSRMLS_DC) /* {{{ */
+static char *zend_parse_arg_impl(int arg_num, zval **arg, const va_list *va, char **spec, char **error, int *severity TSRMLS_DC) /* {{{ */
{
char *spec_walk = *spec;
char c = *spec_walk++;
@@ -617,7 +617,7 @@ static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **sp
}
/* }}} */
-static int zend_parse_arg(int arg_num, zval **arg, va_list *va, char **spec, int quiet TSRMLS_DC) /* {{{ */
+static int zend_parse_arg(int arg_num, zval **arg, const va_list *va, char **spec, int quiet TSRMLS_DC) /* {{{ */
{
char *expected_type = NULL, *error = NULL;
int severity = E_WARNING;
@@ -647,7 +647,7 @@ static int zend_parse_arg(int arg_num, zval **arg, va_list *va, char **spec, int
}
/* }}} */
-static int zend_parse_va_args(int num_args, char *type_spec, va_list *va, int flags TSRMLS_DC) /* {{{ */
+static int zend_parse_va_args(int num_args, char *type_spec, const va_list *va, int flags TSRMLS_DC) /* {{{ */
{
char *spec_walk;
int c, i;
@@ -871,6 +871,7 @@ ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr
object = va_arg(va, zval **);
ce = va_arg(va, zend_class_entry *);
*object = this_ptr;
+
if (ce && !instanceof_function(Z_OBJCE_P(this_ptr), ce TSRMLS_CC)) {
zend_error(E_CORE_ERROR, "%s::%s() must be derived from %s::%s",
ce->name, get_active_function_name(TSRMLS_C), Z_OBJCE_P(this_ptr)->name, get_active_function_name(TSRMLS_C));
@@ -907,6 +908,7 @@ ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC,
object = va_arg(va, zval **);
ce = va_arg(va, zend_class_entry *);
*object = this_ptr;
+
if (ce && !instanceof_function(Z_OBJCE_P(this_ptr), ce TSRMLS_CC)) {
if (!quiet) {
zend_error(E_CORE_ERROR, "%s::%s() must be derived from %s::%s",
@@ -933,7 +935,7 @@ ZEND_API int _array_init(zval *arg, uint size ZEND_FILE_LINE_DC) /* {{{ */
}
/* }}} */
-static int zend_merge_property(zval **value TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
+static int zend_merge_property(zval **value TSRMLS_DC, int num_args, va_list args, const zend_hash_key *hash_key) /* {{{ */
{
/* which name should a numeric property have ? */
if (hash_key->nKeyLength) {
@@ -1396,7 +1398,7 @@ ZEND_API int add_get_index_stringl(zval *arg, ulong index, const char *str, uint
}
/* }}} */
-ZEND_API int add_property_long_ex(zval *arg, char *key, uint key_len, long n TSRMLS_DC) /* {{{ */
+ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, long n TSRMLS_DC) /* {{{ */
{
zval *tmp;
zval *z_key;
@@ -1414,7 +1416,7 @@ ZEND_API int add_property_long_ex(zval *arg, char *key, uint key_len, long n TSR
}
/* }}} */
-ZEND_API int add_property_bool_ex(zval *arg, char *key, uint key_len, int b TSRMLS_DC) /* {{{ */
+ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, int b TSRMLS_DC) /* {{{ */
{
zval *tmp;
zval *z_key;
@@ -1432,7 +1434,7 @@ ZEND_API int add_property_bool_ex(zval *arg, char *key, uint key_len, int b TSRM
}
/* }}} */
-ZEND_API int add_property_null_ex(zval *arg, char *key, uint key_len TSRMLS_DC) /* {{{ */
+ZEND_API int add_property_null_ex(zval *arg, const char *key, uint key_len TSRMLS_DC) /* {{{ */
{
zval *tmp;
zval *z_key;
@@ -1450,7 +1452,7 @@ ZEND_API int add_property_null_ex(zval *arg, char *key, uint key_len TSRMLS_DC)
}
/* }}} */
-ZEND_API int add_property_resource_ex(zval *arg, char *key, uint key_len, long n TSRMLS_DC) /* {{{ */
+ZEND_API int add_property_resource_ex(zval *arg, const char *key, uint key_len, long n TSRMLS_DC) /* {{{ */
{
zval *tmp;
zval *z_key;
@@ -1468,7 +1470,7 @@ ZEND_API int add_property_resource_ex(zval *arg, char *key, uint key_len, long n
}
/* }}} */
-ZEND_API int add_property_double_ex(zval *arg, char *key, uint key_len, double d TSRMLS_DC) /* {{{ */
+ZEND_API int add_property_double_ex(zval *arg, const char *key, uint key_len, double d TSRMLS_DC) /* {{{ */
{
zval *tmp;
zval *z_key;
@@ -1486,7 +1488,7 @@ ZEND_API int add_property_double_ex(zval *arg, char *key, uint key_len, double d
}
/* }}} */
-ZEND_API int add_property_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate TSRMLS_DC) /* {{{ */
+ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, char *str, int duplicate TSRMLS_DC) /* {{{ */
{
zval *tmp;
zval *z_key;
@@ -1504,7 +1506,7 @@ ZEND_API int add_property_string_ex(zval *arg, char *key, uint key_len, char *st
}
/* }}} */
-ZEND_API int add_property_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate TSRMLS_DC) /* {{{ */
+ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, char *str, uint length, int duplicate TSRMLS_DC) /* {{{ */
{
zval *tmp;
zval *z_key;
@@ -1522,7 +1524,7 @@ ZEND_API int add_property_stringl_ex(zval *arg, char *key, uint key_len, char *s
}
/* }}} */
-ZEND_API int add_property_zval_ex(zval *arg, char *key, uint key_len, zval *value TSRMLS_DC) /* {{{ */
+ZEND_API int add_property_zval_ex(zval *arg, const char *key, uint key_len, zval *value TSRMLS_DC) /* {{{ */
{
zval *z_key;
@@ -1702,7 +1704,7 @@ ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *mod
}
/* }}} */
-ZEND_API void zend_check_magic_method_implementation(zend_class_entry *ce, zend_function *fptr, int error_type TSRMLS_DC) /* {{{ */
+ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, int error_type TSRMLS_DC) /* {{{ */
{
char lcname[16];
int name_len;
@@ -2043,7 +2045,7 @@ ZEND_API int zend_startup_module(zend_module_entry *module) /* {{{ */
}
/* }}} */
-ZEND_API int zend_get_module_started(char *module_name) /* {{{ */
+ZEND_API int zend_get_module_started(const char *module_name) /* {{{ */
{
zend_module_entry *module;
@@ -2122,7 +2124,7 @@ int module_registry_cleanup(zend_module_entry *module TSRMLS_DC) /* {{{ */
}
/* }}} */
-int module_registry_unload_temp(zend_module_entry *module TSRMLS_DC) /* {{{ */
+int module_registry_unload_temp(const zend_module_entry *module TSRMLS_DC) /* {{{ */
{
return (module->type == MODULE_TEMPORARY) ? ZEND_HASH_APPLY_REMOVE : ZEND_HASH_APPLY_STOP;
}
@@ -2213,7 +2215,7 @@ ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *or
}
/* }}} */
-ZEND_API int zend_register_class_alias_ex(char *name, int name_len, zend_class_entry *ce TSRMLS_DC) /* {{{ */
+ZEND_API int zend_register_class_alias_ex(const char *name, int name_len, zend_class_entry *ce TSRMLS_DC) /* {{{ */
{
char *lcname = zend_str_tolower_dup(name, name_len);
int ret;
@@ -2227,7 +2229,7 @@ ZEND_API int zend_register_class_alias_ex(char *name, int name_len, zend_class_e
}
/* }}} */
-ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length, zend_bool is_ref, int num_symbol_tables, ...) /* {{{ */
+ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_length, zend_bool is_ref, int num_symbol_tables, ...) /* {{{ */
{
HashTable *symbol_table;
va_list symbol_table_list;
@@ -2304,7 +2306,7 @@ ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_
}
/* }}} */
-static int zend_is_callable_check_class(char *name, int name_len, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */
+static int zend_is_callable_check_class(const char *name, int name_len, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */
{
int ret = 0;
zend_class_entry **pce;
@@ -2962,7 +2964,7 @@ ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */
}
/* }}} */
-ZEND_API int zend_declare_property_ex(zend_class_entry *ce, char *name, int name_length, zval *property, int access_type, char *doc_comment, int doc_comment_len TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type, char *doc_comment, int doc_comment_len TSRMLS_DC) /* {{{ */
{
zend_property_info property_info;
HashTable *target_symbol_table;
@@ -3134,13 +3136,13 @@ ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, char *name, int
}
/* }}} */
-ZEND_API int zend_declare_class_constant(zend_class_entry *ce, char *name, size_t name_length, zval *value TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value TSRMLS_DC) /* {{{ */
{
return zend_hash_update(&ce->constants_table, name, name_length+1, &value, sizeof(zval *), NULL);
}
/* }}} */
-ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, char *name, size_t name_length TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length TSRMLS_DC) /* {{{ */
{
zval *constant;
@@ -3155,7 +3157,7 @@ ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, char *name,
}
/* }}} */
-ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, char *name, size_t name_length, long value TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, long value TSRMLS_DC) /* {{{ */
{
zval *constant;
@@ -3170,7 +3172,7 @@ ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, char *name,
}
/* }}} */
-ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, char *name, size_t name_length, zend_bool value TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_bool value TSRMLS_DC) /* {{{ */
{
zval *constant;
@@ -3185,7 +3187,7 @@ ZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, char *name,
}
/* }}} */
-ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, char *name, size_t name_length, double value TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value TSRMLS_DC) /* {{{ */
{
zval *constant;
@@ -3200,7 +3202,7 @@ ZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, char *name
}
/* }}} */
-ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, char *name, size_t name_length, char *value, size_t value_length TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length TSRMLS_DC) /* {{{ */
{
zval *constant;
@@ -3216,7 +3218,7 @@ ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, char *nam
}
/* }}} */
-ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, char *name, size_t name_length, char *value TSRMLS_DC) /* {{{ */
+ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value TSRMLS_DC) /* {{{ */
{
return zend_declare_class_constant_stringl(ce, name, name_length, value, strlen(value) TSRMLS_CC);
}
@@ -3294,7 +3296,7 @@ ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object,
}
/* }}} */
-ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, char *name, int name_length, char *value TSRMLS_DC) /* {{{ */
+ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, char *name, int name_length, const char *value TSRMLS_DC) /* {{{ */
{
zval *tmp;
@@ -3306,7 +3308,7 @@ ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object,
}
/* }}} */
-ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, char *value, int value_len TSRMLS_DC) /* {{{ */
+ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, const char *value, int value_len TSRMLS_DC) /* {{{ */
{
zval *tmp;
@@ -3401,7 +3403,7 @@ ZEND_API int zend_update_static_property_double(zend_class_entry *scope, char *n
}
/* }}} */
-ZEND_API int zend_update_static_property_string(zend_class_entry *scope, char *name, int name_length, char *value TSRMLS_DC) /* {{{ */
+ZEND_API int zend_update_static_property_string(zend_class_entry *scope, char *name, int name_length, const char *value TSRMLS_DC) /* {{{ */
{
zval *tmp;
@@ -3413,7 +3415,7 @@ ZEND_API int zend_update_static_property_string(zend_class_entry *scope, char *n
}
/* }}} */
-ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, char *name, int name_length, char *value, int value_len TSRMLS_DC) /* {{{ */
+ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, char *name, int name_length, const char *value, int value_len TSRMLS_DC) /* {{{ */
{
zval *tmp;
Oops, something went wrong.

0 comments on commit cf7384a

Please sign in to comment.