Skip to content

Type normalisation in embind #7292

@mejedi

Description

@mejedi

IRT marshalling, T, T& and const/volatile variants of T and T& are effectively the same.

Embind refuses to marshall volatile–qualified objects, so let's forget them for the time being. (Fails with an odd error message in emscripten/val.h.)

There are two parts to marshalling: emscripten::internal::BindingType<T> providing toWireType()/fromWireType() and emscripten::internal::TypeID<T>, providing the type ID.

In the set of BindingType<T> overloads, there are overloads reducing const T -> T, T& -> T and so forth.

There's no such normalisation for TypeID<T>. Due to the lack of normalisation, certain features fail in corner cases. For instance, embind normally refuses to pass raw pointers around, the check implemented as TypeID overload. However:

using namespace emscripten;

// Fails as expected at compile time
val::global("console").call<void>("log", static_cast<void *>(nullptr));

void *p = nullptr;
val::global("console").call<void>("log", p); // Actually compiles!

The normalisation for type ID-s is actually performed, but at a lower level: depending on compile options, it is either typeid() operator, or in LightTypeID.

Proposal

Perform normalisation for TypeID the same way it's done for BindingType<T> (add template specialisations).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions