Hi, First, the actual patch is working but Implementation and behavior may change following all comments. This is still a work in progress and all comments/contributions from everybody are welcome :)
That said : On 9 May 2011 21:23, Stas Malyshev <smalys...@sugarcrm.com> wrote: > Hi! > > > Objects are only instantiated when requested (getAnnotations() or >> getAnnotation()) >> > > So how this happens - does the class store the text of the annotation? Or > expressions in the call are evaluated and stored, but the object is not > instantiated? > What if I call getAnnotation() repeatedly - are they re-instantiated or > stored somewhere, and if so - where? Annotations are stored in a HashTable of zend_annotation. struct _zend_annotation { char *annotation_name; unsigned int aname_len; HashTable *values; zval *instance; /* This is not permanent */ }; Once you call the getAnnotation method the reflection class will evaluate all expressions and instantiate the object. A reference of the object is then saved in the instance member of the structure. However, we have a plan to move this instance somewhere else like in a EG. > > > 2. What is permissible in the arguments of annotation - e.g. can I put any >>> expression there? >>> >> >> You are allowed to use any scalar value + array + any object that >> implements ReflectionAnnotation interface. >> > > By scalar value you mean constant value? Are constants allowed? Yes constants are allowed. Otherwise you can use annotation and static scalar (same thing as default value of class properties for example) > > > 3. What<Foo(<Bar>)> actually means and how it is supposed to be parsed? >>> >> >> It would instantiate a class Bar and would pass it as an instance of >> Foo that is also being created when doing getAnnotations() or >> getAnnotation('Foo') >> > > So when exactly Bar is instantiated - when getAnnotations() is called? When you call getAnnotation() the reflection method will instantiate Bar, and then instantiate the Foo object using the Bar instance as first parameter of the constructor. > > > 6. Do we need any special support for bytecode caches? >>> >> >> Yes. Every structure which can be annotated now will have a new member >> in their C structure which is annotations, this structure is populated >> at compile time and store all the metadata information. So if you have >> an opcode cache the compilation will not occur, so the annotations >> will be NULL. That's why the opcode cache will have to store the >> annotations, so that it can be retrieved every time. >> > > This then should be added to the proposal. > > We will add it Thanks for your feedback. Pierrick > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >