summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-12-30 06:13:32 -0800
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-12-30 06:13:32 -0800
commitd95729f4588acca4a2fbd74043cf2fb32b9ba94f (patch)
treec0bcb12014029f24ff493cc85d3f46417c66a8f0
parent678fb09044c87a2f4bf843bb55eb4b057f1c131a (diff)
parent7c042cfcee984e16e7024a661c95d2cd3eb0b50b (diff)
Merge pull request #10 from BullSoft/master
Add macros for compatible with PHP 5.3
-rw-r--r--Examples/simple/Makefile12
-rw-r--r--Makefile6
-rw-r--r--src/Makefile2
-rw-r--r--src/argument.cpp4
-rw-r--r--src/boolmember.h4
-rw-r--r--src/classinfo.cpp13
-rw-r--r--src/doublemember.h4
-rw-r--r--src/function.cpp4
-rw-r--r--src/includes.h16
-rw-r--r--src/longmember.h4
-rw-r--r--src/nullmember.h4
-rw-r--r--src/stringmember.h6
12 files changed, 69 insertions, 10 deletions
diff --git a/Examples/simple/Makefile b/Examples/simple/Makefile
index cfea8cf..a85c7f8 100644
--- a/Examples/simple/Makefile
+++ b/Examples/simple/Makefile
@@ -1,14 +1,16 @@
CPP = g++
RM = rm -f
-CPP_FLAGS = -Wall -c -I. -O2 -std=c++11
+CPP_FLAGS = -Wall -c -I. -I/home/work/include/ -O2 -std=c++11
+
+PREFIX = /home/work/
-PREFIX = /usr
#Edit these lines to correspond with your own directories
-LIBRARY_DIR = ${PREFIX}/lib/php5/20121212
-PHP_CONFIG_DIR = /etc/php5/cli/conf.d
+LIBRARY_DIR = ${PREFIX}/local/php/lib/php/extensions/no-debug-non-zts-20090626/
+
+PHP_CONFIG_DIR = /home/work/local/php/lib/
LD = g++
-LD_FLAGS = -Wall -shared -O2
+LD_FLAGS = -Wall -Wl,-rpath,/home/work/lib -shared -O2 -L/home/work/lib
RESULT = simple.so
PHPINIFILE = 30-phpcpp.ini
diff --git a/Makefile b/Makefile
index 8209a7e..3b10035 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
-PREFIX = /usr
-INCLUDE_DIR = ${PREFIX}/include
-LIBRARY_DIR = ${PREFIX}/lib
+PREFIX = /home/work/
+INCLUDE_DIR = ${PREFIX}/include/
+LIBRARY_DIR = ${PREFIX}/lib/
all:
cd src; $(MAKE)
diff --git a/src/Makefile b/src/Makefile
index 069024d..c34af85 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,6 +1,6 @@
CPP = g++
RM = rm -f
-PHP_DIR = /usr/include/php5
+PHP_DIR = /home/work/local/php/include/php/
CPP_FLAGS = -c -I. -I${PHP_DIR} -I${PHP_DIR}/main -I${PHP_DIR}/ext -I${PHP_DIR}/Zend -I${PHP_DIR}/TSRM -O2 -std=c++11
LD = g++
diff --git a/src/argument.cpp b/src/argument.cpp
index 7dbf624..e8e7c8a 100644
--- a/src/argument.cpp
+++ b/src/argument.cpp
@@ -28,7 +28,9 @@ Argument::Argument(const char *name, Type type, bool required, bool byref)
// fill members
_info->name = name;
_info->name_len = strlen(name);
+#if PHP_VERSION_ID >= 50400
_info->type_hint = type == arrayType || type == callableType ? type : 0;
+#endif
_info->class_name = NULL;
_info->class_name_len = 0;
_info->allow_null = false;
@@ -54,7 +56,9 @@ Argument::Argument(const char *name, const char *classname, bool nullable, bool
// fill members
_info->name = name;
_info->name_len = strlen(name);
+#if PHP_VERSION_ID >= 50400
_info->type_hint = objectType;
+#endif
_info->class_name = classname;
_info->class_name_len = strlen(classname);
_info->allow_null = nullable;
diff --git a/src/boolmember.h b/src/boolmember.h
index fa482f3..84d7d44 100644
--- a/src/boolmember.h
+++ b/src/boolmember.h
@@ -51,7 +51,11 @@ public:
*/
virtual void declare(struct _zend_class_entry *entry, const char *name, int size, int flags)
{
+#if PHP_VERSION_ID >= 50400
zend_declare_property_bool(entry, name, size, _value, flags);
+#else
+ zend_declare_property_bool(entry, (char *) name, size, _value, flags);
+#endif
}
};
diff --git a/src/classinfo.cpp b/src/classinfo.cpp
index 81edf4f..04123b3 100644
--- a/src/classinfo.cpp
+++ b/src/classinfo.cpp
@@ -61,7 +61,11 @@ static zend_object_value create_object(zend_class_entry *type TSRMLS_DC)
while (base->parent) base = base->parent;
// retrieve the classinfo object
+#if PHP_VERSION_ID >= 50400
_ClassInfo *info = (_ClassInfo *)base->info.user.doc_comment;
+#else
+ _ClassInfo *info = (_ClassInfo *)base->doc_comment;
+#endif
// store the class
object->php.ce = type;
@@ -74,7 +78,12 @@ static zend_object_value create_object(zend_class_entry *type TSRMLS_DC)
zend_hash_init(object->php.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
// initialize the properties
+#if PHP_VERSION_ID < 50399
+ zend_hash_copy(object->php.properties, &(type->default_properties),
+ (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
object_properties_init(&(object->php), type);
+#endif
// the thing we're going to return
zend_object_value result;
@@ -126,7 +135,11 @@ void _ClassInfo::initialize(TSRMLS_DC)
_entry = zend_register_internal_class(&entry TSRMLS_CC);
// store pointer to the class in the unused doc_comment member
+#if PHP_VERSION_ID >= 50400
_entry->info.user.doc_comment = (const char *)this;
+#else
+ _entry->doc_comment = (char *)this;
+#endif
// initialize the entry
initialize(_entry);
diff --git a/src/doublemember.h b/src/doublemember.h
index f03b248..e3b75eb 100644
--- a/src/doublemember.h
+++ b/src/doublemember.h
@@ -51,7 +51,11 @@ public:
*/
virtual void declare(struct _zend_class_entry *entry, const char *name, int size, int flags)
{
+#if PHP_VERSION_ID >= 50400
zend_declare_property_double(entry, name, size, _value, flags);
+#else
+ zend_declare_property_double(entry, (char *)name, size, _value, flags);
+#endif
}
};
diff --git a/src/function.cpp b/src/function.cpp
index 3269448..376b453 100644
--- a/src/function.cpp
+++ b/src/function.cpp
@@ -113,7 +113,9 @@ void Function::fill(zend_function_entry *entry, const char *classname, bool pub)
entry->flags = classname ? (pub ? ZEND_ACC_PUBLIC : ZEND_ACC_PROTECTED) : 0;
// we should fill the first argument as well
+#if PHP_VERSION_ID >= 50400
fill((zend_internal_function_info *)entry->arg_info, classname);
+#endif
}
/**
@@ -121,6 +123,7 @@ void Function::fill(zend_function_entry *entry, const char *classname, bool pub)
* @param info Info to be filled
* @param classname Optional classname
*/
+#if PHP_VERSION_ID >= 50400
void Function::fill(zend_internal_function_info *info, const char *classname) const
{
// fill in all the members, note that return reference is false by default,
@@ -140,6 +143,7 @@ void Function::fill(zend_internal_function_info *info, const char *classname) co
// passing by reference is not used
info->pass_rest_by_reference = false;
}
+#endif
/**
* End of namespace
diff --git a/src/includes.h b/src/includes.h
index 933e317..501a71d 100644
--- a/src/includes.h
+++ b/src/includes.h
@@ -76,3 +76,19 @@
#include "methodmember.h"
#include "arithmetic.h"
+#ifndef ZVAL_COPY_VALUE
+#define ZVAL_COPY_VALUE(z, v) \
+ do { \
+ (z)->value = (v)->value; \
+ Z_TYPE_P(z) = Z_TYPE_P(v); \
+ } while (0)
+#endif
+
+#ifndef INIT_PZVAL_COPY
+#define INIT_PZVAL_COPY(z, v) \
+ do { \
+ ZVAL_COPY_VALUE(z, v); \
+ Z_SET_REFCOUNT_P(z, 1); \
+ Z_UNSET_ISREF_P(z); \
+ } while (0)
+#endif
diff --git a/src/longmember.h b/src/longmember.h
index 2d0be50..b35c316 100644
--- a/src/longmember.h
+++ b/src/longmember.h
@@ -51,7 +51,11 @@ public:
*/
virtual void declare(struct _zend_class_entry *entry, const char *name, int size, int flags)
{
+#if PHP_VERSION_ID >= 50400
zend_declare_property_long(entry, name, size, _value, flags);
+#else
+ zend_declare_property_long(entry, (char *) name, size, _value, flags);
+#endif
}
};
diff --git a/src/nullmember.h b/src/nullmember.h
index 6312709..3fdb6b3 100644
--- a/src/nullmember.h
+++ b/src/nullmember.h
@@ -43,7 +43,11 @@ public:
*/
virtual void declare(struct _zend_class_entry *entry, const char *name, int size, int flags)
{
+#if PHP_VERSION_ID >= 50400
zend_declare_property_null(entry, name, size, flags);
+#else
+ zend_declare_property_null(entry, (char *) name, size, flags);
+#endif
}
};
diff --git a/src/stringmember.h b/src/stringmember.h
index 83432e3..d5af4a5 100644
--- a/src/stringmember.h
+++ b/src/stringmember.h
@@ -58,7 +58,11 @@ public:
*/
virtual void declare(struct _zend_class_entry *entry, const char *name, int size, int flags)
{
- zend_declare_property_stringl(entry, name, size, _value.c_str(), _value.size(), flags);
+#if PHP_VERSION_ID >= 50400
+ zend_declare_property_stringl(entry, name, size, _value.c_str(), _value.size(), flags);
+#else
+ zend_declare_property_stringl(entry, (char*) name, size, (char *) _value.c_str(), _value.size(), flags);
+#endif
}
};