diff options
author | Mark Spruiell <mes@zeroc.com> | 2007-06-19 11:25:17 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2007-06-19 11:25:17 -0700 |
commit | ddcfe70b4f05fb00e466486fc19076147f79298d (patch) | |
tree | acfa4428263b22b3f9226d04a3fe8f910bd21bdd /php/src | |
parent | For UDP multicast bind to the multicast address rather than 0.0.0.0 unless on... (diff) | |
download | ice-ddcfe70b4f05fb00e466486fc19076147f79298d.tar.bz2 ice-ddcfe70b4f05fb00e466486fc19076147f79298d.tar.xz ice-ddcfe70b4f05fb00e466486fc19076147f79298d.zip |
bug 2245 - adding support for protected class data members
Diffstat (limited to 'php/src')
-rw-r--r-- | php/src/IcePHP/Marshal.cpp | 17 | ||||
-rw-r--r-- | php/src/IcePHP/Profile.cpp | 11 |
2 files changed, 25 insertions, 3 deletions
diff --git a/php/src/IcePHP/Marshal.cpp b/php/src/IcePHP/Marshal.cpp index 0671b484da8..8b0f6118d73 100644 --- a/php/src/IcePHP/Marshal.cpp +++ b/php/src/IcePHP/Marshal.cpp @@ -1247,12 +1247,25 @@ IcePHP::MemberMarshaler::unmarshal(zval* zv, const Ice::InputStreamPtr& is TSRML return false; } - if(add_property_zval(zv, const_cast<char*>(_name.c_str()), val) == FAILURE) + // + // The add_property_zval function fails if the data member has protected visibility. + // As a workaround, before calling the function we change the current scope to be that + // of the object. + // + zend_class_entry *oldScope = EG(scope); + EG(scope) = Z_OBJCE_P(zv); + + int status = add_property_zval(zv, const_cast<char*>(_name.c_str()), val); + + EG(scope) = oldScope; // Restore the previous scope. + + if(status == FAILURE) { php_error_docref(0 TSRMLS_CC, E_ERROR, "unable to set member `%s'", _name.c_str()); return false; } - zval_ptr_dtor(&val); // add_property_zval increments the refcount + + zval_ptr_dtor(&val); // add_property_zval increments the refcount. return true; } diff --git a/php/src/IcePHP/Profile.cpp b/php/src/IcePHP/Profile.cpp index 5d00cef2494..84a9c2c22ba 100644 --- a/php/src/IcePHP/Profile.cpp +++ b/php/src/IcePHP/Profile.cpp @@ -1126,7 +1126,16 @@ IcePHP::CodeVisitor::visitOperation(const Slice::OperationPtr& p) void IcePHP::CodeVisitor::visitDataMember(const Slice::DataMemberPtr& p) { - _out << "public $" << fixIdent(p->name()) << ';' << endl; + Slice::ContainedPtr cont = Slice::ContainedPtr::dynamicCast(p->container()); + assert(cont); + if(Slice::ClassDefPtr::dynamicCast(cont) && (cont->hasMetaData("protected") || p->hasMetaData("protected"))) + { + _out << "protected $" << fixIdent(p->name()) << ';' << endl; + } + else + { + _out << "public $" << fixIdent(p->name()) << ';' << endl; + } } void |