Note
If your object can only be reflected into JS by creating it, not by
retrieving it from somewhere, you can skip steps 1 and 2 above and
instead add `'wrapperCache': False` to your descriptor. You will
need to flag the functions that return your object as
[`[NewObject]`](https://webidl.spec.whatwg.org/#NewObject) in
the Web IDL. If your object is not refcounted then the return value of
functions that return it should return a UniquePtr.
## C++ reflections of Web IDL constructs
### C++ reflections of Web IDL operations (methods)
A Web IDL operation is turned into a method call on the underlying C++
object. The return type and argument types are determined [as described
below](#c-reflections-of-webidl-constructs). In addition to those, all [methods that are
allowed to throw](#throws-getterthrows-setterthrows) will get an `ErrorResult&` argument
appended to their argument list. Non-static methods that use certain
Web IDL types like `any` or `object` will get a `JSContext*`
argument prepended to the argument list. Static methods will be passed a
[`const GlobalObject&`](#globalobject) for the relevant global and
can get a `JSContext*` by calling `Context()` on it.
The name of the C++ method is simply the name of the Web IDL operation
with the first letter converted to uppercase.
Web IDL overloads are turned into C++ overloads: they simply call C++
methods with the same name and different signatures.
For example, this Web IDL:
``` webidl
interface MyInterface
{
undefined doSomething(long number);
double doSomething(MyInterface? otherInstance);
[Throws]
MyInterface doSomethingElse(optional long maybeNumber);
[Throws]
undefined doSomethingElse(MyInterface otherInstance);
undefined doTheOther(any something);
undefined doYetAnotherThing(optional boolean actuallyDoIt = false);
static undefined staticOperation(any arg);
};
```
will require these method declarations:
``` cpp
class MyClass
{
void DoSomething(int32_t a number);
double DoSomething(MyClass* aOtherInstance);
already_AddRefed