Pointer Retrieval in JavaScript/Emscripten

Hi, I’m programming an HTML5 wrapper for a custom integration for GameMaker Studio and my question is:

Is it possible to create an FMOD object in JavaScript from a raw memory address number?

For example, I tried instantiating a new FMOD.EventInstance(), but there are no available constructors to do so. It would be really helpful, like in the C# integration if it were possible to pass the pointer number into a constructor and get a usable copy of the bound object. Is this possible via Emscripten or is there a similar workaround to achieve the same goal?

Thank you.

Best regards,

Hi Aaron,
the C# objects you are talking about are wrappers that are not really part of FMOD, so the real eventInstance is still dynamically created, and a very small struct is used in the wrapper to hold it.

I’m guessing this isn’t really going to help you with any memory management, all FMOD objects are allocated internally and the handle is passed back to the user. They usually include memory from different (shared) locations as well so you cannot allocate 1 block of memory for an fmod object.

This is a higher level observation which is not platform or html5 specific.

Hi Brett,
Thank you for your response. The specific reason I’m asking is that Game Maker only allows async callbacks to receive values that are doubles or strings, so passing a JS wrapper object directly to Game Maker isn’t working. It automatically converts it into a garbage double. (I could pass the JS object by using a GM script instead, but then callbacks wouldn’t be portable with the current Desktop implementation)
Is there any other way to create a wrapper in JS containing the object handle, with only the pointer value of the previously created object? My goal would be being able to access the wrapper object from the Game Maker callback without needing to manage something like a JS map of pointer keys with wrapper object references manually.

Edit: Also for clarity, I’m wrapping function calls to fmodstudioL.js wasm from an intermediary js file, not building from emscripten.

Game maker really needs to handle JS objects, you’re not supposed to deal with pointers in javascript.

It’s good to hear that, I’ll send a query and try to find a workaround in the meantime.