Hi,
In a recent thread ("Stop #including jsapi.h everywhere!"), I wrote
the following.
> Next time you're thinking of adding a |#include "jsapi.h"| statement,
> please think about whether a forward declaration would suffice -- i.e.
> if you are only using public JS types (i.e. not functions), and only
> using them as pointers, references, or parameters in function
> declarations. (Forward-declaring JS_PUBLIC_API types is harder; ask
> me for help if you need to do that.)
>
> [BTW, you might think "these popular forward declarations should be in
> a header of their own, to avoid some repetition". That's a reasonable
> idea, and there is a file jspubtd.h that serves this purpose... sort
> of. It contains numerous forward declarations (many more than is
> needed in 98% of cases), but it also defines some types, so its
> purpose is muddied. So I'm not doing that for now, though creating a
> new file "js/ForwardDecls.h" (or somesuch) is a possibility in the
> future.]
That new file now exists
(https://bugzilla.mozilla.org/show_bug.cgi?id=911020) and is called
js/TypeDecls.h. It's very small, and only contains the most
widely-used type declarations (JSObject, JSContext, JS::Value,
JS::Handle, jsid, jschar, and a few others) so you can include it in
good conscience. I've replaced all the existing forward declarations
of these types with includes of this file.
Thanks.
Nick
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform