From cf25fa0b9636d232c63f01824d66289ab9a89b81 Mon Sep 17 00:00:00 2001 From: valmat Date: Tue, 25 Nov 2014 23:36:07 +0600 Subject: Used variadic templates instead of code duplication --- zend/value.cpp | 380 --------------------------------------------------------- 1 file changed, 380 deletions(-) (limited to 'zend/value.cpp') diff --git a/zend/value.cpp b/zend/value.cpp index 501feb7..8d1e78f 100644 --- a/zend/value.cpp +++ b/zend/value.cpp @@ -850,191 +850,6 @@ Value Value::operator()() const return exec(0, NULL); } -/** - * Call the function - if the variable holds a callable thing - * @param p0 The first parameter - * @return Value - */ -Value Value::operator()(Value p0) const -{ - // array of parameters - zval **params[1] = { &p0._val }; - - // call the function - return exec(1, params); -} - -/** - * Call the function - if the variable holds a callable thing - * @param p0 The first parameter - * @param p1 The second parameter - * @return Value - */ -Value Value::operator()(Value p0, Value p1) const -{ - // array of parameters - zval **params[2] = { &p0._val, &p1._val }; - - // call the function - return exec(2, params); -} - -/** - * Call the function - if the variable holds a callable thing - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @return Value - */ -Value Value::operator()(Value p0, Value p1, Value p2) const -{ - // array of parameters - zval **params[3] = { &p0._val, &p1._val, &p2._val }; - - // call the function - return exec(3, params); -} - -/** - * Call the function - if the variable holds a callable thing - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @return Value - */ -Value Value::operator()(Value p0, Value p1, Value p2, Value p3) const -{ - // array of parameters - zval **params[4] = { &p0._val, &p1._val, &p2._val, &p3._val }; - - // call the function - return exec(4, params); -} - -/** - * Call the function - if the variable holds a callable thing - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @return Value - */ -Value Value::operator()(Value p0, Value p1, Value p2, Value p3, Value p4) const -{ - // array of parameters - zval **params[5] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val }; - - // call the function - return exec(5, params); -} - -/** - * Call the function - if the variable holds a callable thing - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @param p5 The sixth parameter - * @return Value - */ -Value Value::operator()(Value p0, Value p1, Value p2, Value p3, Value p4, Value p5) const -{ - // array of parameters - zval **params[6] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val, &p5._val }; - - // call the function - return exec(6, params); -} - -/** - * Call the function - if the variable holds a callable thing - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @param p5 The sixth parameter - * @param p6 The seventh parameter - * @return Value - */ -Value Value::operator()(Value p0, Value p1, Value p2, Value p3, Value p4, Value p5, Value p6) const -{ - // array of parameters - zval **params[7] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val, &p5._val, &p6._val }; - - // call the function - return exec(7, params); -} - -/** - * Call the function - if the variable holds a callable thing - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @param p5 The sixth parameter - * @param p6 The seventh parameter - * @param p7 The eighth parameter - * @return Value - */ -Value Value::operator()(Value p0, Value p1, Value p2, Value p3, Value p4, Value p5, Value p6, Value p7) const -{ - // array of parameters - zval **params[8] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val, &p5._val, &p6._val, &p7._val }; - - // call the function - return exec(8, params); -} - -/** - * Call the function - if the variable holds a callable thing - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @param p5 The sixth parameter - * @param p6 The seventh parameter - * @param p7 The eighth parameter - * @param p8 The ninth parameter - * @return Value - */ -Value Value::operator()(Value p0, Value p1, Value p2, Value p3, Value p4, Value p5, Value p6, Value p7, Value p8) const -{ - // array of parameters - zval **params[9] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val, &p5._val, &p6._val, &p7._val, &p8._val }; - - // call the function - return exec(9, params); -} - -/** - * Call the function - if the variable holds a callable thing - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @param p5 The sixth parameter - * @param p6 The seventh parameter - * @param p7 The eighth parameter - * @param p8 The ninth parameter - * @param p9 The tenth parameter - * @return Value - */ -Value Value::operator()(Value p0, Value p1, Value p2, Value p3, Value p4, Value p5, Value p6, Value p7, Value p8, Value p9) const -{ - // array of parameters - zval **params[10] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val, &p5._val, &p6._val, &p7._val, &p8._val, &p9._val }; - - // call the function - return exec(10, params); -} - /** * Call the method - if the variable holds an object with the given method * @param name name of the method to call @@ -1046,201 +861,6 @@ Value Value::call(const char *name) return exec(name, 0, NULL); } -/** - * Call the method - if the variable holds an object with the given method - * @param name name of the method to call - * @param p0 The first parameter - * @return Value - */ -Value Value::call(const char *name, Value p0) -{ - // array of parameters - zval **params[] = { &p0._val }; - - // call with zero parameters - return exec(name, 1, params); -} - -/** - * Call the method - if the variable holds an object with the given method - * @param name name of the method to call - * @param p0 The first parameter - * @param p1 The second parameter - * @return Value - */ -Value Value::call(const char *name, Value p0, Value p1) -{ - // array of parameters - zval **params[] = { &p0._val, &p1._val }; - - // call with zero parameters - return exec(name, 2, params); -} - -/** - * Call the method - if the variable holds an object with the given method - * @param name name of the method to call - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @return Value - */ -Value Value::call(const char *name, Value p0, Value p1, Value p2) -{ - // array of parameters - zval **params[] = { &p0._val, &p1._val, &p2._val }; - - // call with zero parameters - return exec(name, 3, params); -} - -/** - * Call the method - if the variable holds an object with the given method - * @param name name of the method to call - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @return Value - */ -Value Value::call(const char *name, Value p0, Value p1, Value p2, Value p3) -{ - // array of parameters - zval **params[] = { &p0._val, &p1._val, &p2._val, &p3._val }; - - // call with zero parameters - return exec(name, 4, params); -} - -/** - * Call the method - if the variable holds an object with the given method - * @param name name of the method to call - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @return Value - */ -Value Value::call(const char *name, Value p0, Value p1, Value p2, Value p3, Value p4) -{ - // array of parameters - zval **params[] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val }; - - // call with zero parameters - return exec(name, 5, params); -} - -/** - * Call the method - if the variable holds an object with the given method - * @param name name of the method to call - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @param p5 The sixth parameter - * @return Value - */ -Value Value::call(const char *name, Value p0, Value p1, Value p2, Value p3, Value p4, Value p5) -{ - // array of parameters - zval **params[] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val, &p5._val }; - - // call with zero parameters - return exec(name, 6, params); -} - -/** - * Call the method - if the variable holds an object with the given method - * @param name name of the method to call - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @param p5 The sixth parameter - * @param p6 The seventh parameter - * @return Value - */ -Value Value::call(const char *name, Value p0, Value p1, Value p2, Value p3, Value p4, Value p5, Value p6) -{ - // array of parameters - zval **params[] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val, &p5._val, &p6._val }; - - // call with zero parameters - return exec(name, 7, params); -} - -/** - * Call the method - if the variable holds an object with the given method - * @param name name of the method to call - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @param p5 The sixth parameter - * @param p6 The seventh parameter - * @param p7 The eighth parameter - * @return Value - */ -Value Value::call(const char *name, Value p0, Value p1, Value p2, Value p3, Value p4, Value p5, Value p6, Value p7) -{ - // array of parameters - zval **params[] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val, &p5._val, &p6._val, &p7._val }; - - // call with zero parameters - return exec(name, 8, params); -} - -/** - * Call the method - if the variable holds an object with the given method - * @param name name of the method to call - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @param p5 The sixth parameter - * @param p6 The seventh parameter - * @param p7 The eighth parameter - * @param p8 The ninth parameter - * @return Value - */ -Value Value::call(const char *name, Value p0, Value p1, Value p2, Value p3, Value p4, Value p5, Value p6, Value p7, Value p8) -{ - // array of parameters - zval **params[] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val, &p5._val, &p6._val, &p7._val, &p8._val }; - - // call with zero parameters - return exec(name, 9, params); -} - -/** - * Call the method - if the variable holds an object with the given method - * @param name name of the method to call - * @param p0 The first parameter - * @param p1 The second parameter - * @param p2 The third parameter - * @param p3 The fourth parameter - * @param p4 The fifth parameter - * @param p5 The sixth parameter - * @param p6 The seventh parameter - * @param p7 The eighth parameter - * @param p8 The ninth parameter - * @param p9 The tenth parameter - * @return Value - */ -Value Value::call(const char *name, Value p0, Value p1, Value p2, Value p3, Value p4, Value p5, Value p6, Value p7, Value p8, Value p9) -{ - // array of parameters - zval **params[] = { &p0._val, &p1._val, &p2._val, &p3._val, &p4._val, &p5._val, &p6._val, &p7._val, &p8._val, &p9._val }; - - // call with zero parameters - return exec(name, 10, params); -} - /** * Helper function that runs the actual call * @param object The object to call it on -- cgit v1.2.3 From 7320131b8caada0e7237e33ef4e0340577627ef4 Mon Sep 17 00:00:00 2001 From: valmat Date: Wed, 26 Nov 2014 01:13:36 +0600 Subject: Marked `noexcept` all move constructors and assigment operators See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html --- include/array.h | 4 ++-- include/byref.h | 2 +- include/byval.h | 2 +- include/class.h | 2 +- include/classbase.h | 2 +- include/global.h | 4 ++-- include/hashmember.h | 2 +- include/hiddenpointer.h | 2 +- include/object.h | 2 +- include/value.h | 4 ++-- zend/value.cpp | 4 ++-- 11 files changed, 15 insertions(+), 15 deletions(-) (limited to 'zend/value.cpp') diff --git a/include/array.h b/include/array.h index 4d6b6b1..d238862 100644 --- a/include/array.h +++ b/include/array.h @@ -38,7 +38,7 @@ public: * Move constructor from a value object * @param value */ - Array(Value &&value) : Value(std::move(value)) + Array(Value &&value) noexcept : Value(std::move(value)) { // type must be valid if (value.type() != Type::Array) throw FatalError("Moving a non-array to an array variable"); @@ -107,7 +107,7 @@ public: * @param value * @return Array */ - Array &operator=(Value &&value) + Array &operator=(Value &&value) noexcept { // skip self assignment if (this == &value) return *this; diff --git a/include/byref.h b/include/byref.h index 317c5c6..ff60981 100644 --- a/include/byref.h +++ b/include/byref.h @@ -45,7 +45,7 @@ public: * Move constructor * @param argument */ - ByRef(ByRef &&argument) : Argument(argument) {} + ByRef(ByRef &&argument) noexcept : Argument(argument) {} /** * Destructor diff --git a/include/byval.h b/include/byval.h index 66f9b8f..3606df7 100644 --- a/include/byval.h +++ b/include/byval.h @@ -45,7 +45,7 @@ public: * Move constructor * @param argument */ - ByVal(ByVal &&argument) : Argument(argument) {} + ByVal(ByVal &&argument) noexcept : Argument(argument) {} /** * Destructor diff --git a/include/class.h b/include/class.h index cffc7bd..9257213 100644 --- a/include/class.h +++ b/include/class.h @@ -48,7 +48,7 @@ public: * Move constructor * @param that */ - Class(Class &&that) : ClassBase(std::move(that)) {} + Class(Class &&that) noexcept : ClassBase(std::move(that)) {} /** * Destructor diff --git a/include/classbase.h b/include/classbase.h index 9f0bac3..1129298 100644 --- a/include/classbase.h +++ b/include/classbase.h @@ -85,7 +85,7 @@ public: * Move constructor * @param that */ - ClassBase(ClassBase &&that) : _impl(std::move(that._impl)) {} + ClassBase(ClassBase &&that) noexcept : _impl(std::move(that._impl)) {} /** * Destructor diff --git a/include/global.h b/include/global.h index ae54212..4593e5d 100644 --- a/include/global.h +++ b/include/global.h @@ -34,7 +34,7 @@ public: * Move constructor * @param global */ - Global(Global &&global) : Value(std::move(global)), _name(std::move(global._name)), _exists(global._exists) {} + Global(Global &&global) noexcept : Value(std::move(global)), _name(std::move(global._name)), _exists(global._exists) {} /** * Destructor @@ -70,7 +70,7 @@ public: * @return Global */ /* - Global &operator=(Global &&global) + Global &operator=(Global &&global) noexcept { // skip self assignment if (&global == this) return *this; diff --git a/include/hashmember.h b/include/hashmember.h index 6853228..b5b6c17 100644 --- a/include/hashmember.h +++ b/include/hashmember.h @@ -579,7 +579,7 @@ protected: * Move constructor * @param value Other element */ -// HashMember(HashMember &&member) : +// HashMember(HashMember &&member) noexcept : // _parent(std::move(member._parent)), _index(std::move(member._index)) {} private: diff --git a/include/hiddenpointer.h b/include/hiddenpointer.h index dc981c0..5465ebb 100644 --- a/include/hiddenpointer.h +++ b/include/hiddenpointer.h @@ -84,7 +84,7 @@ public: * Move constructor * @param that */ - HiddenPointer(HiddenPointer &&that) : _allocated(that._allocated), _buffer(that._buffer) + HiddenPointer(HiddenPointer &&that) noexcept : _allocated(that._allocated), _buffer(that._buffer) { // the other object is no longer allocated that._allocated = false; diff --git a/include/object.h b/include/object.h index 98e2553..2e92f6a 100644 --- a/include/object.h +++ b/include/object.h @@ -119,7 +119,7 @@ public: * @param value * @return ForcedValue */ - Object &operator=(Value &&value) + Object &operator=(Value &&value) noexcept { // skip self assignment if (this == &value) return *this; diff --git a/include/value.h b/include/value.h index d6f8da6..eef06cb 100644 --- a/include/value.h +++ b/include/value.h @@ -130,7 +130,7 @@ public: * Move constructor * @param value */ - Value(Value &&that); + Value(Value &&that) noexcept; /** * Destructor @@ -142,7 +142,7 @@ public: * @param value * @return Value */ - Value &operator=(Value &&value); + Value &operator=(Value &&value) noexcept; /** * Assignment operator for various types diff --git a/zend/value.cpp b/zend/value.cpp index 8d1e78f..230fe04 100644 --- a/zend/value.cpp +++ b/zend/value.cpp @@ -283,7 +283,7 @@ Value::Value(const Value &that) * Move constructor * @param value */ -Value::Value(Value &&that) : _val(that._val) +Value::Value(Value &&that) noexcept: _val(that._val) { // clear the other object that._val = nullptr; @@ -394,7 +394,7 @@ int Value::refcount() const * @param value * @return Value */ -Value &Value::operator=(Value &&value) +Value &Value::operator=(Value &&value) noexcept { // skip self assignment if (this == &value) return *this; -- cgit v1.2.3