emscripten-core/emscripten

Documentation doesn't match implementation in WebIDL_Binder: Use of [Const] attribute for methods

Open

#14.747 geöffnet am 23. Juli 2021

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C++ (3.519 Forks)batch import
help wanted

Repository-Metriken

Stars
 (27.361 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 19T 10h) (147 gemergte PRs in 30 T)

Beschreibung

Hello,

Noticed a mismatch between documentation and implementation related to the use of [Const] attributes for method return types in the tools/webidl_binder.py

From the documentation:

C++ arguments or return types that use const can be specified in IDL using [Const].

For example, the following code fragments show the C++ and IDL for a function that returns a constant pointer object.

//C++ const myObject* getAsConst(); // WebIDL [Const] myObject getAsConst();

So the documentation states that [Const] attribute applies to the return type of the method.

However, in reality, using the [Const] attribute in the manner above results in the method being marked as const, not the return type. This is particularly a problem when generating the Javascript implementation class for an abstract C++ interface.

Example:

[Const] DOMString foo();

turns into

char* foo() const in the generated Glue C++ source file.

The documentation never mentions that const methods are supported, so I believe this is a bug in the implementation.

Contributor Guide