emscripten-core / emscripten-core/emscripten
Web-IDL: `sequence<long>` converted to just `int` in `glue.cpp`
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
**Version of emscripten/emsdk:**
```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.51 (c0c2ca1314672a25699846b4663701bcb6f69cca)
clang version 18.0.0git (https://github.com/llvm/llvm-project f2464ca317bfeeedddb7cbdea3c2c8ec487890bb)
Target: wasm32-unknown-emscripten
Thread model: posix
```
**Failing command line in full:**
`tools/webidl_binder MyContainer.idl glue`
The above command generates an incorrect glue.cpp file.
# Source files:
```cpp
// MyContainer.hpp
#include
constexpr auto N = 1000;
class MyContainer {
public:
void load(const std::array &vals);
const std::array, N> &dump() const;
private:
std::array, N> elems;
};
```
```cpp
// MyContainer.cpp
#include "MyContainer.hpp"
#include
using std::array;
using std::size_t;
void MyContainer::load(const array &vals) {
for (size_t i = 0; i < N; ++i) {
for (size_t j = 0; j < N; ++j) {
elems[i][j] = vals[i];
}
}
}
const array, N> &MyContainer::dump() const { return elems; }
```
```cpp
// MyContainer.idl
interface MyContainer {
void MyContainer();
void load(sequence vals);
sequence> dump();
};
```
```cpp
// glue.cpp
#include
#include
EM_JS_DEPS(webidl_binder, "$intArrayFromString,$UTF8ToString");
extern "C" {
// Define custom allocator functions that we can force export using
// EMSCRIPTEN_KEEPALIVE. This avoids all webidl users having to add
// malloc/free to -sEXPORTED_FUNCTIONS.
EMSCRIPTEN_KEEPALIVE void webidl_free(void* p) { free(p); }
EMSCRIPTEN_KEEPALIVE void* webidl_malloc(size_t len) { return malloc(len); }
// VoidPtr
void EMSCRIPTEN_KEEPALIVE emscripten_bind_VoidPtr___destroy___0(void** self) {
delete self;
}
// MyContainer
MyContainer* EMSCRIPTEN_KEEPALIVE emscripten_bind_MyContainer_MyContainer_0() {
return new MyContainer();
}
void EMSCRIPTEN_KEEPALIVE emscripten_bind_MyContainer_load_1(MyContainer* self, int vals) {
self->load(vals);
}
int EMSCRIPTEN_KEEPALIVE emscripten_bind_MyContainer_dump_0(MyContainer* self) {
return self->dump();
}
void EMSCRIPTEN_KEEPALIVE emscripten_bind_MyContainer___destroy___0(MyContainer* self) {
delete self;
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.