Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Fastest way to get device & interface and other Qs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fastest way to get device & interface and other Qs



Thanks for the explanation, Godfrey.

It sounds like the object on the left and the "self" passed as a parameter will always be the same, so I will probably wrap these up in my own C++ objects to try to clean it up a bit. We'll see.

Right now I'm just battling some of the device requests, trying to get them to work.

Thanks again!

--
Rick

On Feb 11, 2010, at 14:56:48, Godfrey van der Linden wrote:

> G'day, Rick.
>
> The odd syntax is a result of Apple's implementation of MS's COM in the CFPlugIn apis. I actually had a lot to do with that decision so maybe I can clarify a few points.
>
> If I hadn't suffered from slight NIH during the design of IOKit I would have put a strong case together for using COM style of design inside the kernel too rather than our roll-your-own C++ with dynamic load time patching, you have no idea how hard it was to get that working at load time!
>
> COM has the advantage of having a clean inheritance model and very clean interfaces. Binary compatibility just falls out from the design.  API suppliers can advance their implementation but developers need only choose which version of that interface they require. Believe me this is heaven compared to trying to advance C++ or even C structure of pointer to function APIs.
>
> For MS their use of COM is wrapped in C++ magic foo that uses the COM base class as its root class and then inherits from there. Unfortunately gcc in the early naughties just didn't give a bugger about binary compatibility and there was no way of leveraging the C++ virtual dispatch to wrap COM dispatch cleanly without compiler changes.
>
> Finally the weird function call syntax is what C++ does when it calls a virtual function, made explicit.
>
> Godfrey
>
> On 2010-02-11, at 7:31 AM, Rick Mann wrote:
>
>> 2) This question is to address my curiosity. I thought that the IOKit classes used to be actual C++ classes, and now it seems they're C structs and function pointers. Before, when they were classes, you still needed syntactic histrionics to call a method:
>>
>> 	(*foo)->method(foo, ...)
>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Fastest way to get device & interface and other Qs (From: Rick Mann <email@hidden>)
 >Re: Fastest way to get device & interface and other Qs (From: Godfrey van der Linden <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.