Skip to content

Commit

Permalink
update php7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jun 5, 2019
1 parent f203be6 commit 814e82a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion module/ngx_http_hi_module/lib/php-x/base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ Variant _call(zval *object, zval *func)
}
}

Variant include(string file)
Variant include(const string& file)
{
zend_file_handle file_handle;
int ret = php_stream_open_for_zend_ex(file.c_str(), &file_handle, USE_PATH | STREAM_OPEN_FOR_INCLUDE);
Expand Down
2 changes: 1 addition & 1 deletion module/ngx_http_hi_module/lib/php-x/extension.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void Extension::registerConstant(const char *name, float v)
zend_register_double_constant(name, strlen(name), v, CONST_CS | CONST_PERSISTENT, module.module_number);
}

void Extension::registerConstant(const char *name, string &v)
void Extension::registerConstant(const char *name, const string &v)
{
zend_register_stringl_constant(name, strlen(name), (char *) v.c_str(), v.length(), CONST_CS | CONST_PERSISTENT, module.module_number);
}
Expand Down
40 changes: 20 additions & 20 deletions module/ngx_http_hi_module/lib/php-x/phpx.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Variant
init();
ZVAL_STRINGL(&val, str, len);
}
Variant(std::string &str)
Variant(const std::string &str)
{
init();
ZVAL_STRINGL(&val, str.c_str(), str.length());
Expand Down Expand Up @@ -438,7 +438,7 @@ class Variant
Variant _tmp(v);
return equals(_tmp);
}
bool operator ==(std::string &v)
bool operator ==(const std::string &v)
{
Variant _tmp(v);
return equals(_tmp);
Expand Down Expand Up @@ -507,9 +507,9 @@ static inline bool is_callable(const Variant &fn)
return zend_is_callable(const_cast<Variant &>(fn).ptr(), 0, nullptr);
}

Variant include(std::string file);
Variant include(const std::string& file);

static inline int version_compare(std::string s1, std::string s2)
static inline int version_compare(const std::string& s1, const std::string& s2)
{
return php_version_compare(s1.c_str(), s2.c_str());
}
Expand Down Expand Up @@ -545,7 +545,7 @@ class String
{
value = zend_string_init(str, len, 0);
}
String(std::string &str)
String(const std::string& str)
{
value = zend_string_init(str.c_str(), str.length(), 0);
}
Expand Down Expand Up @@ -600,7 +600,7 @@ class String
{
return memcmp(str, value->val, value->len) == 0;
}
inline bool equals(std::string &str)
inline bool equals(const std::string &str)
{
if (str.length() != value->len)
{
Expand Down Expand Up @@ -651,7 +651,7 @@ class String
value->len, 0, flags, (char *) charset.c_str());
}

inline String unescape(int flags, std::string charset)
inline String unescape(int flags, const std::string& charset)
{
#if PHP_VERSION_ID < 70200
return php_unescape_html_entities((unsigned char *) value->val,
Expand Down Expand Up @@ -860,7 +860,7 @@ class Array: public Variant
{
add_next_index_string(ptr(), str);
}
void append(std::string &str)
void append(const std::string &str)
{
add_next_index_stringl(ptr(), str.c_str(), str.length());
}
Expand Down Expand Up @@ -918,7 +918,7 @@ class Array: public Variant
{
add_assoc_string(ptr(), key, (char * )v);
}
inline void set(const char *key, std::string &v)
inline void set(const char *key, const std::string &v)
{
add_assoc_stringl(ptr(), key, (char* )v.c_str(), v.length());
}
Expand Down Expand Up @@ -998,7 +998,7 @@ class Array: public Variant
{
return zend_hash_str_exists(Z_ARRVAL_P(ptr()), key, strlen(key));
}
inline bool exists(std::string &key)
inline bool exists(const std::string &key)
{
return zend_hash_str_exists(Z_ARRVAL_P(ptr()), key.c_str(), key.length());
}
Expand Down Expand Up @@ -1413,14 +1413,14 @@ class Object: public Variant
{
zend_update_property(Z_OBJCE_P(ptr()), ptr(), name, strlen(name), v.ptr());
}
inline void set(const char *name, std::string &v)
{
zend_update_property_stringl(Z_OBJCE_P(ptr()), ptr(), name, strlen(name), v.c_str(), v.length());
}
inline void set(const char *name, std::string v)
inline void set(const char *name, const std::string &v)
{
zend_update_property_stringl(Z_OBJCE_P(ptr()), ptr(), name, strlen(name), v.c_str(), v.length());
}
// inline void set(const char *name, const std::string& v)
// {
// zend_update_property_stringl(Z_OBJCE_P(ptr()), ptr(), name, strlen(name), v.c_str(), v.length());
// }
inline void set(const char *name, const char *v)
{
zend_update_property_string(Z_OBJCE_P(ptr()), ptr(), name, strlen(name), v);
Expand Down Expand Up @@ -1639,15 +1639,15 @@ class Class
{
return ce;
}
Variant getStaticProperty(std::string p_name)
Variant getStaticProperty(const std::string& p_name)
{
if (!activated)
{
return nullptr;
}
return Variant(zend_read_static_property(ce, p_name.c_str(), p_name.length(), 1));
}
bool setStaticProperty(std::string p_name, Variant value)
bool setStaticProperty(const std::string& p_name, Variant value)
{
if (!activated)
{
Expand All @@ -1656,7 +1656,7 @@ class Class
value.addRef();
return zend_update_static_property(ce, p_name.c_str(), p_name.length(), value.ptr()) == SUCCESS;
}
static Variant get(const char *name, std::string p_name)
static Variant get(const char *name, const std::string& p_name)
{
zend_class_entry *_tmp_ce = getClassEntry(name);
if (!_tmp_ce)
Expand All @@ -1665,7 +1665,7 @@ class Class
}
return Variant(zend_read_static_property(_tmp_ce, p_name.c_str(), p_name.length(), 1));
}
static bool set(const char *name, std::string p_name, Variant value)
static bool set(const char *name, const std::string& p_name, Variant value)
{
zend_class_entry *_tmp_ce = getClassEntry(name);
if (!_tmp_ce)
Expand Down Expand Up @@ -1827,7 +1827,7 @@ class Extension
void registerConstant(const char *name, float v);
void registerConstant(const char *name, const char *v);
void registerConstant(const char *name, const char *v, size_t len);
void registerConstant(const char *name, std::string &v);
void registerConstant(const char *name, const std::string &v);

bool require(const char *name, const char *version = nullptr);

Expand Down
4 changes: 2 additions & 2 deletions module/ngx_http_hi_module/lib/php-x/phpx_embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class VM {
std::string s(script);
eval(s);
}
void eval(std::string& script)
void eval(const std::string& script)
{
zend_first_try
{
Expand All @@ -54,7 +54,7 @@ class VM {
}
zend_end_try();
}
inline Variant include(std::string file)
inline Variant include(const std::string& file)
{
zend_file_handle file_handle;
int ret = php_stream_open_for_zend_ex(file.c_str(), &file_handle, USE_PATH | STREAM_OPEN_FOR_INCLUDE);
Expand Down

0 comments on commit 814e82a

Please sign in to comment.