summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2015-02-05 21:00:22 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2015-02-05 21:00:22 +0100
commit1432d5f4bb053fcaa12a9b7e50c4d3787eb5194b (patch)
treed1ed68102d5266303deeebeb506e1d607acabf70
parent45d59165cb6b4c80fd26d555eae8ca8f2a7d0d6f (diff)
parentae07ef4cf606147c77b6ba472956e2793e251ba6 (diff)
Merge branch 'master' of https://github.com/CopernicaMarketingSoftware/PHP-CPP
-rw-r--r--include/argument.h21
-rw-r--r--include/array.h8
-rw-r--r--include/platform.h27
-rw-r--r--include/value.h6
-rw-r--r--phpcpp.h1
-rw-r--r--zend/constantimpl.h5
-rw-r--r--zend/includes.h1
7 files changed, 68 insertions, 1 deletions
diff --git a/include/argument.h b/include/argument.h
index ddb6390..f45a43a 100644
--- a/include/argument.h
+++ b/include/argument.h
@@ -144,10 +144,31 @@ private:
};
/**
+ * Old Visual C++ environments do not support initializer lists
+ */
+#if defined(_MSC_VER) && _MSC_VER < 1800
+
+/**
+ * For old visual c++ compilers, arguments should be passed as vectors
+ */
+using Arguments = std::vector<Argument>;
+
+/**
+ * Other compilers, and visual C++ 2013 do support initializer lists
+ */
+#else
+
+/**
* A list of arguments can be supplied to methods
* @type Arguments
*/
using Arguments = std::initializer_list<Argument>;
+
+/**
+ * End of visual C++ check
+ */
+#endif
+
/**
* End of namespace
diff --git a/include/array.h b/include/array.h
index 882670a..02fe4c4 100644
--- a/include/array.h
+++ b/include/array.h
@@ -57,12 +57,18 @@ public:
*/
template <typename T>
Array(const std::map<std::string,T> &value) : Value(value) {}
-
+
+// old visual c++ environments have no support for initializer lists
+# if !defined(_MSC_VER) || _MSC_VER >= 1800
+
/**
* Constructor from an initializer list
* @param value
*/
Array(const std::initializer_list<Value> &value) : Value(value) {}
+
+// end of visual c++ check
+# endif
/**
* Destructor
diff --git a/include/platform.h b/include/platform.h
new file mode 100644
index 0000000..561cd60
--- /dev/null
+++ b/include/platform.h
@@ -0,0 +1,27 @@
+/**
+ * Platform.h
+ *
+ * Macro that we use to find out whether we run on 64bit or 32bit
+ * platforms.
+ *
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ * @copyright 2015 Copernica BV
+ */
+
+// Check windows
+#if _WIN32 || _WIN64
+#if _WIN64
+#define PHPCPP_64BIT
+#else
+#define PHPCPP_32BIT
+#endif
+#endif
+
+// Check GCC and clang
+#if __GNUC__ || __clang__
+#if __x86_64__ || __ppc64__
+#define PHPCPP_64BIT
+#else
+#define PHPCPP_32BIT
+#endif
+#endif
diff --git a/include/value.h b/include/value.h
index b87574b..2440532 100644
--- a/include/value.h
+++ b/include/value.h
@@ -81,6 +81,9 @@ public:
for (auto &elem : input) setRaw(i++, elem);
}
+ // old visual c++ environments have no support for initializer lists
+# if !defined(_MSC_VER) || _MSC_VER >= 1800
+
/**
* Constructor from an initializer list
* @param value
@@ -94,6 +97,9 @@ public:
// set all elements
for (auto &elem : value) setRaw(i++, elem);
}
+
+ // end of visual c++ check
+# endif
/**
* Constructor from a map (this will create an associative array)
diff --git a/phpcpp.h b/phpcpp.h
index 0b0beb0..16c1690 100644
--- a/phpcpp.h
+++ b/phpcpp.h
@@ -28,6 +28,7 @@
* Include all headers files that are related to this library
*/
#include <phpcpp/noexcept.h>
+#include <phpcpp/platform.h>
#include <phpcpp/version.h>
#include <phpcpp/inivalue.h>
#include <phpcpp/ini.h>
diff --git a/zend/constantimpl.h b/zend/constantimpl.h
index 7320a8b..1fb1676 100644
--- a/zend/constantimpl.h
+++ b/zend/constantimpl.h
@@ -127,8 +127,13 @@ public:
break;
case IS_LONG:
+#ifdef PHPCPP_32BIT
+ // 32bit systems find this difficult
+ clss.property(_name, (int32_t)Z_LVAL(_constant.value), Php::Const);
+#else
// set a long constant
clss.property(_name, Z_LVAL(_constant.value), Php::Const);
+#endif
break;
case IS_DOUBLE:
diff --git a/zend/includes.h b/zend/includes.h
index 44d2714..529efa5 100644
--- a/zend/includes.h
+++ b/zend/includes.h
@@ -47,6 +47,7 @@
* Include other files from this library
*/
#include "../include/noexcept.h"
+#include "../include/platform.h"
#include "../include/version.h"
#include "../include/inivalue.h"
#include "../include/ini.h"