Open Bug 694114 Opened 13 years ago Updated 2 years ago

Add ability to statically assert from C++ that a class is 'builtinclass'

Categories

(Core :: XPConnect, defect)

defect

Tracking

()

REOPENED

People

(Reporter: bjacob, Unassigned)

References

Details

This is a follow-up from bug 638328 comment 19. We need to be able to statically assert from C++ that a class is marked "builtinclass". Probably the easiest would be

template<typename T> struct is_builtinclass {
  enum { value = 0 };
};

and then the IDL generator would generate for each class that is builtinclass, a specialization like:

template<> struct is_builtinclass<MyClass> {
  enum { value = 1 };
};
Blocks: 638328
And once this is possible, we want to use that in bug 638328, in GetConcreteObject in WebGLContext.h
I don't entirely understand this.  That an interface is builtinclass doesn't imply that there is only one implementation of it and that it's safe to static_cast to a concrete class.
Sure, people writing non-Gecko C++ can make it fail. I think we don't care about that if it means we can make things a lot faster.
(In reply to Peter Van der Beken [:peterv] from comment #3)
> Sure, people writing non-Gecko C++ can make it fail. I think we don't care
> about that if it means we can make things a lot faster.

I agree, I just don't know that it's worth adding asserts for this if it's not actually guaranteeing much.
My worry is forgetting to add a builtinclass somewhere and then letting JS pass random objects that we'll try to cast because we assume only C++ can implement the interface.
I agree with comment 5, that is my worry too.
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INACTIVE
Status: RESOLVED → REOPENED
Resolution: INACTIVE → ---
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.