Re: using Zend: extensions module: Accessing instance data internally
| From: | O'Neil Delpratt | Date: | Thu, 06 Mar 2014 17:26:09 +0000 |
| Subject: | Re: using Zend: extensions module: Accessing instance data internally | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-72980@lists.php.net to get a copy of this message | ||
On 06/03/14 17:08, Chris Wright wrote:
On 6 March 2014 16:12, O'Neil Delpratt <oneil@saxonica.com> wrote:The work around which I have now tried and it works is to create the XdmValue via the the SaxonProcessor class as a factory function and not independently. A separate issue I have is how to maintain thread safety in a NTS version of PHP. The SaxonProcessor contains some third-party dependency library which restricts more than one instance created at anyone time. I notice that some time PHP requests are not closed before another one starts which results in the a crash of the library. Thanks and kind regards, O'Neil -- O'Neil Delpratt Software Developer, Saxonica Limited Email: oneil@saxonica.com <mailto:oneil@saxonica.com> Tel: +44 118 946 5894 Web: http://www.saxonica.com Saxonica Community Site: http://dev.saxonica.com Saxonica Bug tracking System: https://saxonica.plan.io/Hi, I have two created two php objects in my extension module called SaxonProcessor and XdmValue: struct saxonProcessor_object {I'm not 100% sure what you are asking here so if this comes off as patronising then I'm sorry :-P It sounds like what you have is simply a classic circular reference thru dependency injection problem. A good paradigm for solving this is to have one object create the other and inject itself in the process. Can you explain the userland PHP API you are trying to create here? From reading the documentation for Saxon I can't see why a Processor would have a member which is an XdmValue or, to be honest, vice versa. They both seem to operate independently of each other. Thanks, Chris The problem is the SaxonProcessor is the main class stores configuration information shared across all the processors, for example a namepool is cached.zend_object std; SaxonProcessor * saxonProcessor; XsltProcessor *xsltProcessor; XQueryProcessor *xqueryProcessor; XdmValue * xdmValue; char * stylesheetFile; char * stylesheetStr; char * queryFile; char * queryStr;}; struct xdmValue_object {zend_object std; XdmValue * xdmValue;}; In the XdmValue_object I need to pass internally the C++ SaxonProcessor object in the saxonProcessor_object, but I am not sure how to do this because in the XdmValue constructor the getThis() method allows me to gain access to the xdmValue_object struct: xdmValue_object *obj = (xdmValue_object *)zend_object_store_get_object(getThis() TSRMLS_CC);Any ideas?