Skip to content

Commit 94003aa

Browse files
merged changes
2 parents 9dce354 + 6eaeb00 commit 94003aa

12 files changed

Lines changed: 192 additions & 50 deletions

File tree

.clang_complete

Lines changed: 0 additions & 8 deletions
This file was deleted.

Makefile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
# installed in the default directory, you can change that here.
1818
#
1919

20-
PHP_CONFIG = php-config
21-
20+
PHP_CONFIG = php-config
21+
UNAME := $(shell uname)
2222

2323
#
2424
# Installation directory
@@ -30,9 +30,16 @@ PHP_CONFIG = php-config
3030
# and /usr/local/lib. You can of course change it to whatever suits you best
3131
#
3232

33-
INSTALL_PREFIX = /usr
33+
# Since OSX 10.10 Yosemite, /usr/include gives problem
34+
# So, let's switch to /usr/local as default instead.
35+
ifeq ($(UNAME), Darwin)
36+
INSTALL_PREFIX = /usr/local
37+
else
38+
INSTALL_PREFIX = /usr
39+
endif
40+
3441
INSTALL_HEADERS = ${INSTALL_PREFIX}/include
35-
INSTALL_LIB = ${INSTALL_PREFIX}/lib
42+
INSTALL_LIB = ${INSTALL_PREFIX}/lib
3643

3744

3845
#
@@ -204,6 +211,7 @@ ${PHP_STATIC_OBJECTS}:
204211

205212
install:
206213
${MKDIR} ${INSTALL_HEADERS}/phpcpp
214+
${MKDIR} ${INSTALL_LIB}
207215
${CP} phpcpp.h ${INSTALL_HEADERS}
208216
${CP} include/*.h ${INSTALL_HEADERS}/phpcpp
209217
if [ -e ${PHP_SHARED_LIBRARY} ]; then \
@@ -218,3 +226,7 @@ install:
218226
sudo ldconfig; \
219227
fi
220228

229+
uninstall:
230+
${RM} ${INSTALL_HEADERS}/phpcpp*
231+
${RM} ${INSTALL_LIB}/libphpcpp.*
232+

common/modifiers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const int Const = 0;
3030
/**
3131
* Modifiers that are supported for methods and properties
3232
*/
33-
const int MethodModifiers = Final | Public | Protected | Private;
33+
const int MethodModifiers = Final | Public | Protected | Private | Static;
3434
const int PropertyModifiers = Final | Public | Protected | Private | Const | Static;
3535

3636
/**

documentation/classes-and-objects.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ <h1>Classes and objects</h1>
118118
<p>
119119
To make the class accessible from PHP, you must add it to the extension
120120
object inside the get_module() function. The Php::Class template class should be
121-
be used for that. The template parameter should be your
121+
used for that. The template parameter should be your
122122
implementation class, so that the Php::Class object internally knows which
123123
class to instantiate the moment the "new" operator is used inside a PHP script.
124124
</p>

documentation/lambda-functions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ <h2>Calling anonymous PHP functions from C++</h2>
209209
object: you can assign it to other Php::Value objects, and you
210210
can use it as a parameter when you call user space PHP functions.
211211
In the above example we do exactly that: we call the user space
212-
my_iterate() function with our own 'multiply_by_two' C++ function.
212+
my_array_map() function with our own 'multiply_by_two' C++ function.
213213
</p>
214214
<h2>Signature of the C++ function</h2>
215215
<p>

include/class.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ class PHPCPP_EXPORT Class : private ClassBase
109109
* @param args Argument descriptions
110110
* @return Class Same object to allow chaining
111111
*/
112-
template <void (*callback)() > Class<T> &method(const char *name, int flags, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, flags, args); return *this; }
113-
template <Value (*callback)() > Class<T> &method(const char *name, int flags, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, flags, args); return *this; }
114-
template <void (*callback)(Parameters &parameters) > Class<T> &method(const char *name, int flags, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, flags, args); return *this; }
115-
template <Value (*callback)(Parameters &parameters) > Class<T> &method(const char *name, int flags, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, flags, args); return *this; }
116-
template <void (*callback)() > Class<T> &method(const char *name, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Public, args); return *this; }
117-
template <Value (*callback)() > Class<T> &method(const char *name, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Public, args); return *this; }
118-
template <void (*callback)(Parameters &parameters) > Class<T> &method(const char *name, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Public, args); return *this; }
119-
template <Value (*callback)(Parameters &parameters) > Class<T> &method(const char *name, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Public, args); return *this; }
112+
template <void (*callback)() > Class<T> &method(const char *name, int flags, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Static | flags, args); return *this; }
113+
template <Value (*callback)() > Class<T> &method(const char *name, int flags, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Static | flags, args); return *this; }
114+
template <void (*callback)(Parameters &parameters) > Class<T> &method(const char *name, int flags, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Static | flags, args); return *this; }
115+
template <Value (*callback)(Parameters &parameters) > Class<T> &method(const char *name, int flags, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Static | flags, args); return *this; }
116+
template <void (*callback)() > Class<T> &method(const char *name, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Static | Public, args); return *this; }
117+
template <Value (*callback)() > Class<T> &method(const char *name, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Static | Public, args); return *this; }
118+
template <void (*callback)(Parameters &parameters) > Class<T> &method(const char *name, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Static | Public, args); return *this; }
119+
template <Value (*callback)(Parameters &parameters) > Class<T> &method(const char *name, const Arguments &args = {}) { ClassBase::method(name, &ZendCallable::invoke<callback>, Static | Public, args); return *this; }
120120

121121
/**
122122
* Add a regular method to the class

include/value.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,13 @@ class PHPCPP_EXPORT Value : private HashParent
380380
* Check if the value is of a certain type
381381
* @return bool
382382
*/
383-
bool isNull() const { return type() == Type::Null; }
384-
bool isNumeric() const { return type() == Type::Numeric; }
385-
bool isBool() const { return type() == Type::False || type() == Type::True; }
386-
bool isString() const { return type() == Type::String; }
387-
bool isFloat() const { return type() == Type::Float; }
388-
bool isObject() const { return type() == Type::Object; }
389-
bool isArray() const { return type() == Type::Array; }
383+
bool isNull() const;
384+
bool isNumeric() const;
385+
bool isBool() const;
386+
bool isString() const;
387+
bool isFloat() const;
388+
bool isObject() const;
389+
bool isArray() const;
390390
bool isScalar() const { return isNull() || isNumeric() || isBool() || isString() || isFloat(); }
391391
bool isCallable() const;
392392

include/zval.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ class Zval
6767
// reinterpret and dereference
6868
return *const_cast<struct _zval_struct*>(reinterpret_cast<const struct _zval_struct*>(&_buffer));
6969
}
70+
71+
/**
72+
* In case this is a reference, dereference it into a zval.. In case it isn't
73+
* the actual value is returned.
74+
* @return struct _zval_struct*
75+
*/
76+
struct _zval_struct *dereference() const;
7077
};
7178

7279
/**

zend/classimpl.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -825,12 +825,6 @@ zval *ClassImpl::toZval(Value &&value, int type, zval *rv)
825825
// if the zval has a reference count we must decrease it
826826
Z_TRY_DELREF_P(result);
827827

828-
// the pointer from the value may now be destroyed
829-
// (it was allocated by the value and detached)
830-
// we do not actually "destroy" the value here,
831-
// even if the refcount reaches 0 here!
832-
delete result;
833-
834828
// return the pointer to the value
835829
return rv;
836830
}

zend/inivalue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Php {
1818
*/
1919
int64_t IniValue::numericValue() const
2020
{
21-
return zend_ini_long(const_cast<char*>(_name.c_str()), _name.size()+1, _isorig);
21+
return zend_ini_long(const_cast<char*>(_name.c_str()), _name.size(), _isorig);
2222

2323
}
2424

@@ -28,7 +28,7 @@ int64_t IniValue::numericValue() const
2828
*/
2929
const char* IniValue::rawValue() const
3030
{
31-
return zend_ini_string(const_cast<char*>(_name.c_str()), _name.size()+1, _isorig);
31+
return zend_ini_string(const_cast<char*>(_name.c_str()), _name.size(), _isorig);
3232
}
3333

3434
/**
@@ -37,7 +37,7 @@ const char* IniValue::rawValue() const
3737
*/
3838
IniValue::operator double() const
3939
{
40-
return zend_ini_double(const_cast<char*>(_name.c_str()), _name.size()+1, _isorig);
40+
return zend_ini_double(const_cast<char*>(_name.c_str()), _name.size(), _isorig);
4141
}
4242

4343
/**

0 commit comments

Comments
 (0)