I'm doing some toying with XPCOM; in particular I am trying to convert several existing C++ classes to XPCOM components. Could you tell we what is the XPCOM's way to deal with constness?
for example, if I have the following C++ classes: class B; class A { public: virtual int compute(const B&) const = 0; };
How do I enforce constness of A and B in XPCOM IDL? Obviously the following code simply discards all the constness. interface iB; [scriptable, uuid(2be7759a-efce-4830-9fd6-426e3c9776e4)] interface iA : nsISupports { int compute(in iB); }
IDL has no concept of object const-ness. If you want somebody not to modify "B" in your example above, you shouldn't provide any mutation methods on the nsIB interface.
Sometimes in XPCOM we have a read-only version of an interface and a mutable version. See nsIArray (readonly) and nsIMutableArray (extends nsIArray with mutation methods). If you want to pass a "const" array to someone, you hand out nsIArray. If you want to pass a mutable array, you give out nsIMutableArray.
--BDS _______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
