summaryrefslogtreecommitdiff
path: root/src/value.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/value.cpp')
-rw-r--r--src/value.cpp206
1 files changed, 103 insertions, 103 deletions
diff --git a/src/value.cpp b/src/value.cpp
index 5239b33..2a571ab 100644
--- a/src/value.cpp
+++ b/src/value.cpp
@@ -144,9 +144,9 @@ Value::Value(struct _zval_struct *val, bool ref)
// we're going to make will not change the other variable
if (ref && Z_REFCOUNT_P(_val) > 1)
{
- // separate the zval
- SEPARATE_ZVAL_IF_NOT_REF(&_val);
- }
+ // separate the zval
+ SEPARATE_ZVAL_IF_NOT_REF(&_val);
+ }
// we see ourselves as reference too
Z_ADDREF_P(_val);
@@ -216,40 +216,40 @@ Value &Value::operator=(const Value &value)
// skip self assignment
if (this == &value) return *this;
- // is the object a reference?
- if (Z_ISREF_P(_val))
- {
- // the current object is a reference, this means that we should
- // keep the zval object, and copy the other value into it, get
- // the current refcount
- int refcount = Z_REFCOUNT_P(_val);
-
- // clean up the current zval (but keep the zval structure)
- zval_dtor(_val);
-
- // make the copy
- *_val = *value._val;
- zval_copy_ctor(_val);
-
- // restore refcount and reference setting
- Z_SET_ISREF_TO_P(_val, true);
- Z_SET_REFCOUNT_P(_val, refcount);
- }
- else
- {
- // destruct the zval (this function will decrement the reference counter,
- // and only destruct if there are no other references left)
- zval_ptr_dtor(&_val);
-
- // just copy the zval, and the refcounter
- _val = value._val;
-
- // and we have one more reference
- Z_ADDREF_P(_val);
- }
-
- // update the object
- return *this;
+ // is the object a reference?
+ if (Z_ISREF_P(_val))
+ {
+ // the current object is a reference, this means that we should
+ // keep the zval object, and copy the other value into it, get
+ // the current refcount
+ int refcount = Z_REFCOUNT_P(_val);
+
+ // clean up the current zval (but keep the zval structure)
+ zval_dtor(_val);
+
+ // make the copy
+ *_val = *value._val;
+ zval_copy_ctor(_val);
+
+ // restore refcount and reference setting
+ Z_SET_ISREF_TO_P(_val, true);
+ Z_SET_REFCOUNT_P(_val, refcount);
+ }
+ else
+ {
+ // destruct the zval (this function will decrement the reference counter,
+ // and only destruct if there are no other references left)
+ zval_ptr_dtor(&_val);
+
+ // just copy the zval, and the refcounter
+ _val = value._val;
+
+ // and we have one more reference
+ Z_ADDREF_P(_val);
+ }
+
+ // update the object
+ return *this;
}
/**
@@ -262,65 +262,65 @@ Value &Value::operator=(Value &&value)
// skip self assignment
if (this == &value) return *this;
- // is the object a reference?
- if (Z_ISREF_P(_val))
- {
+ // is the object a reference?
+ if (Z_ISREF_P(_val))
+ {
// @todo difference if the other object is a reference or not?
- // the current object is a reference, this means that we should
- // keep the zval object, and copy the other value into it, get
- // the current refcount
- int refcount = Z_REFCOUNT_P(_val);
-
- // clean up the current zval (but keep the zval structure)
- zval_dtor(_val);
-
- // make the copy
- *_val = *value._val;
-
- // restore reference and refcount setting
- Z_SET_ISREF_TO_P(_val, true);
- Z_SET_REFCOUNT_P(_val, refcount);
+ // the current object is a reference, this means that we should
+ // keep the zval object, and copy the other value into it, get
+ // the current refcount
+ int refcount = Z_REFCOUNT_P(_val);
+
+ // clean up the current zval (but keep the zval structure)
+ zval_dtor(_val);
+
+ // make the copy
+ *_val = *value._val;
+
+ // restore reference and refcount setting
+ Z_SET_ISREF_TO_P(_val, true);
+ Z_SET_REFCOUNT_P(_val, refcount);
// how many references did the old variable have?
if (Z_ISREF_P(value._val) > 1)
{
- // the other object already had multiple references, this
- // implies that many other PHP variables are also referring
- // to it, and we still need to store its contents, with one
- // reference less
- Z_DELREF_P(value._val);
-
- // and we need to run the copy constructor on the current
- // value, because we're making a deep copy
- zval_copy_ctor(_val);
- }
- else
- {
- // the last and only reference to the other object was
- // removed, we no longer need it
- FREE_ZVAL(value._val);
-
- // the other object is no longer valid
- value._val = nullptr;
- }
- }
- else
- {
- // destruct the zval (this function will decrement the reference counter,
- // and only destruct if there are no other references left)
- zval_ptr_dtor(&_val);
-
- // just copy the zval completely
- _val = value._val;
-
- // the other object is no longer valid
- value._val = nullptr;
- }
-
- // update the object
- return *this;
+ // the other object already had multiple references, this
+ // implies that many other PHP variables are also referring
+ // to it, and we still need to store its contents, with one
+ // reference less
+ Z_DELREF_P(value._val);
+
+ // and we need to run the copy constructor on the current
+ // value, because we're making a deep copy
+ zval_copy_ctor(_val);
+ }
+ else
+ {
+ // the last and only reference to the other object was
+ // removed, we no longer need it
+ FREE_ZVAL(value._val);
+
+ // the other object is no longer valid
+ value._val = nullptr;
+ }
+ }
+ else
+ {
+ // destruct the zval (this function will decrement the reference counter,
+ // and only destruct if there are no other references left)
+ zval_ptr_dtor(&_val);
+
+ // just copy the zval completely
+ _val = value._val;
+
+ // the other object is no longer valid
+ value._val = nullptr;
+ }
+
+ // update the object
+ return *this;
}
/**
@@ -339,8 +339,8 @@ Value &Value::operator=(int value)
// set new value
ZVAL_LONG(_val, value);
- // update the object
- return *this;
+ // update the object
+ return *this;
}
/**
@@ -359,8 +359,8 @@ Value &Value::operator=(long value)
// set new value
ZVAL_LONG(_val, value);
- // update the object
- return *this;
+ // update the object
+ return *this;
}
/**
@@ -379,8 +379,8 @@ Value &Value::operator=(bool value)
// set new value
ZVAL_BOOL(_val, value);
- // update the object
- return *this;
+ // update the object
+ return *this;
}
/**
@@ -399,8 +399,8 @@ Value &Value::operator=(char value)
// set new value
ZVAL_STRINGL(_val, &value, 1, 1);
- // update the object
- return *this;
+ // update the object
+ return *this;
}
/**
@@ -419,8 +419,8 @@ Value &Value::operator=(const std::string &value)
// set new value
ZVAL_STRINGL(_val, value.c_str(), value.size(), 1);
- // update the object
- return *this;
+ // update the object
+ return *this;
}
/**
@@ -439,8 +439,8 @@ Value &Value::operator=(const char *value)
// set new value
ZVAL_STRING(_val, value, 1);
- // update the object
- return *this;
+ // update the object
+ return *this;
}
/**
@@ -459,8 +459,8 @@ Value &Value::operator=(double value)
// set new value
ZVAL_DOUBLE(_val, value);
- // update the object
- return *this;
+ // update the object
+ return *this;
}
/**