Home  |  Linux  | Mysql  | PHP  | XML
From:Carsten Lucke Date:Sun Apr 27 13:12:05 2008
Subject:Re: Method signature hackery - lsit of type signatures?
Hey Wez,

that was quick! :-) Thank you! These defines were exactly what I was 
looking for. I thought it had to be somewhere in the ObjC runtime but I 
didn't find it anywhere in the docs. Next time I'll stick to the 
header-files in the first place. ;-)

Thanks again! Keep up the great work.

Regards,
- Carsten



Wez Furlong wrote:
> Hi Carsten,
> 
> Signatures are not very well documented, at least, not well enoough for 
> a casual google to yield a guide.
> /usr/include/objc/runtime.h has a set of defines like this:
> 
> #define _C_ID       '@'
> #define _C_CLASS    '#'
> #define _C_SEL      ':'
> #define _C_CHR      'c'
> #define _C_UCHR     'C'
> /* and more */
> 
> so the signature you mentioned:  c@: means:
> 
> return type:  c  (the "char" type)
> first param:  @  (the "id" type, which is a pointer to an obj-c object)
> second param: :  (the "selector" type, which identifies the method to be 
> invoked)
> 
> the first and second parameters are almost always present; they're the 
> implicit "this" and method name.
> 
> Regarding when you need it... if you're working with classes defined by 
> the objective C runtime, we can usually query it to work out the 
> signature automatically.  The delegate example needs you to hint at the 
> signature, because the class is purely defined by PHP based on the 
> method you've declared.  Since PHP is dynamically typed, it's not always 
> possible to infer the correct signature based on the method declaration, 
> and more importantly, there's no way to type hint the return value either.
> 
> Hope that helps,
> 
> --Wez.
> 
> 
> On Apr 27, 2008, at 2:39 PM, Carsten Lucke wrote:
> 
>> Hi all,
>>
>> the README contains a short explanation of the method signature 
>> hackery. Where can I get an overview of what options I have here 
>> (which abbreviation for which type)? I've seen the @c and also @v 
>> (void?). When is it necessary to add a signature and when is it not? I 
>> couldn't find anything about that...
>>
>> Any small hint is highly appreciated. Thanks a lot in advance!
>>
>> Kind regards,
>> - Carsten
>>
>>
>> > Method signature hackery
>> >
>> > The bridge isn't quite smart enough to automatically figure out type 
>> mapping
>> > for everything, particularly if you are declaring a delegate object 
>> that will
>> > act as a sink for events, so you will need to provide hints in some 
>> cases.
>> >
>> > You can provide the hints using doc-comments like this:
>> >
>> > class MyDelegate extends NSObject {
>> >     /** @objc:signature c@: */
>> >     function run_() {
>> >         echo "*** run!\n";
>> >     }
>> > }
>> >
>> > the "c@:" part defines the return type and parameters for the run_ 
>> method; it
>> > is a standard objective-C stype signature.
>>
>> -- 
>> PHP Objective-C Bridge Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
> 
> 
Navigate in group php.objc at sever news.php.net
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants