I need an ArrayBuffer, actually a Uint8Array, passed from JS to my C++ class. 
With embind my c++ class has

     texture(const emscripten::val& data) {
            std::vector<uint8_t> bytes{};
            bytes.resize(data["byteLength"].as<size_t>());
            emscripten::val memory = 
emscripten::val::module_property("HEAP8")["buffer"];
            emscripten::val memoryView = data["constructor"].new_(memory, 
reinterpret_cast<uintptr_t>(bytes.data()), data["length"].as<uint32_t>());
            memoryView.call<void>("set", data);
            ….
     }

How to I do the same using webidl_binder?

In another method of this class, I need to return multiple items including 
something retrieved from module_property. With embind I use an emscripten::val 
as follows:

            val ret = val::object();
            // Find the WebGLTexture for texture.
            val texture = val::module_property("GL")["textures"][texname];
            ret.set("texture", texture);
            ret.set("target", target);
            ret.set("error", error);
            return std::move(ret);

I am trying to figure out how to do the equivalent with webidl_binder. I 
created a

    struct UploadResult {
        val texture;
        GLenum target;
        GLenum error;
    };

in my c++ class and a matching interface in the idl and this is what the method 
is declared to return. My current attempt is

            UploadResult ur;
            val texture = val::module_property("GL")["textures"][texname];
            ur.texture = std::move(texture);
            ur.target = target;
            ur.error = error;
            return std::move(ur);

I am getting errors about “implicitly-deleted default constructor” for both ur 
and val. The use of  `val` here raises another question. How do I look 
something up in module_property?

The webidl_binder documentation fails to describe any interesting uses, 
limiting itself to only the most basic types and operations.

Regards

    -Mark


-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/35785150-59C5-47FB-99DF-9AD3EC2E91E5%40callow.im.

Attachment: signature.asc
Description: Message signed with OpenPGP

Reply via email to