Alex Vincent wrote:
These two models are very different, and I must ask which I should use, and when?

The answer to this question will matter a great deal to me, and affect both the Cheat Sheet and future patches I submit for reviews and checkin to mozilla.org trunk.

From irc://irc.mozilla.org/developers :

        <WeirdAl> nsIVariant... what is that?
        <bsmedberg>       WeirdAl: it's a variant, silly ;-)
        <pkasting>        (Note: the real server, not the anonymous mirror)
        <bsmedberg>       WeirdAl: it can represent any of the core xpidl data 
types, basically
        <WeirdAl> oh! sweet.
        <bsmedberg>       WeirdAl: I *think* that there is automatic xpconnect 
magic that maps variants to native JS types
        <WeirdAl> bsmedberg: I'm trying to figure out when to use nsIArray and 
when to use XPIDL-based arrays, and I was wondering how to put primitive types like 
booleans, numbers, etc. into nsIArray
        <bsmedberg>       WeirdAl: we really need nsIVariantArray
        <WeirdAl> bsmedberg: please don't ask me to write it
        <biesi>   we need nsIArray<T>
        <bsmedberg>       biesi: [iid_is(aIID)] nsITArray
        * bsmedberg     shudders
        <biesi>   wouldn't work for primitive types :)
        <WeirdAl> bsmedberg: I posted to m.d.t.xpcom on the above question, so 
I'm trying to do my homework before writing an article / tutorial / devmo amendment
        <bsmedberg>       WeirdAl: there aren't good guidelines
        <WeirdAl> so it's an either/or situation
        <bsmedberg>       WeirdAl: in/out arrays have to be nsIMutableArray, of 
course
        <bsmedberg>       but for only in or out, it's kinda a tossup
        <bsmedberg>       and depends on the types involved, among other things
        <WeirdAl> well, in the case of nsIRegExpService, it's an array of 
strings
        <bsmedberg>       WeirdAl: sounds like nsIArray would be quite 
cumbersome for that usecase
        <Waldo|mac>       biesi: where some is "a lot", yes -- I still need to 
submit that for addition to the general test-harness
        <biesi>   you can use [array] also for inout, no?
        <bsmedberg>       biesi: I don't think that works
        <NeilAway>        pkasting: how would you check whether a certain 
<input> element is focused
        <WeirdAl> bsmedberg: so the general sense I'm getting is that for 
arrays of a single primitive type, in or out (not inout), use XPIDL-based arrays. For 
anything else, use nsIArray or nsIMutableArray.
        <WeirdAl> does that generally sound right?
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to