问题
I created a FireFox addon a while a go, and noticed it stopped working on FireFox 3.6 Apparently, NSGetModule is being replaced with an NSModule structure, so I have to adapt. I'm coding my product with Delphi, so I have to port the new code to Object Pascal.
If I look over this code: http://mxr.mozilla.org/mozilla-central/source/xpcom/components/Module.h
I notice that the "cid" property of the ContractIDEntry struct, is defined as nsID const *
Does this mean that there's a pointer to a nsID variable in the struct, or that the nsID value is itself part of the struct?
回答1:
The full declaration is this:
struct ContractIDEntry
{
const char* contractid;
nsID const * cid;
};
Just as the declaration of contractid
means that the struct contains a pointer to a char and not that the char is part of the struct, the declaration of cid
means the struct contains a pointer to an nsID. The struct does not contain an nsID, merely a pointer to one.
Technically, it's a pointer that is not allowed to be used to modify the pointed-to value, but Delphi doesn't have that concept, so declare it as just an ordinary pointer.
来源:https://stackoverflow.com/questions/4065202/gecko-nsmodule-contractidentry-nsid-const