Implement director-disown for PHP
This commit is contained in:
parent
3c4342e66a
commit
04bacf689b
2 changed files with 42 additions and 8 deletions
|
|
@ -8,6 +8,8 @@
|
|||
#ifndef SWIG_DIRECTOR_PHP_HEADER_
|
||||
#define SWIG_DIRECTOR_PHP_HEADER_
|
||||
|
||||
#define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||
|
||||
#include <string>
|
||||
#include <exception>
|
||||
#include <map>
|
||||
|
|
@ -76,16 +78,34 @@ namespace Swig {
|
|||
};
|
||||
|
||||
class Director {
|
||||
private:
|
||||
/* flag indicating whether the object is owned by PHP or C++ */
|
||||
mutable bool swig_disown_flag;
|
||||
|
||||
protected:
|
||||
// "mutable" so we can get a non-const pointer to it in const methods.
|
||||
mutable zval swig_self;
|
||||
typedef std::map<void *, GCItem_var> swig_ownership_map;
|
||||
mutable swig_ownership_map swig_owner;
|
||||
|
||||
public:
|
||||
Director(zval *self) {
|
||||
Director(zval *self) : swig_disown_flag(false) {
|
||||
ZVAL_COPY_VALUE(&swig_self, self);
|
||||
}
|
||||
|
||||
~Director() {
|
||||
if (swig_disown_flag) {
|
||||
Z_DELREF(swig_self);
|
||||
}
|
||||
}
|
||||
|
||||
void swig_disown() const {
|
||||
if (!swig_disown_flag) {
|
||||
swig_disown_flag = true;
|
||||
Z_ADDREF(swig_self);
|
||||
}
|
||||
}
|
||||
|
||||
static bool swig_is_overridden_method(const char *cname, zval *z) {
|
||||
zend_string * cname_str = zend_string_init(cname, strlen(cname), 0);
|
||||
zend_class_entry *ce = zend_lookup_class(cname_str);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue