Skip to content

proposal to merge WASM into JNA-InChI #32

@BobHanson

Description

@BobHanson

@johnmay @dan2097

I have the following test code working in JavaScript using WASM:

  var logger = IxaFunctions.IXA_STATUS_Create();
  var nativeMol = IxaFunctions.IXA_MOL_Create(logger);
  IxaFunctions.IXA_MOL_ReserveSpace(logger, nativeMol, 3, 3, 3);  
  var nativeAtom = IxaFunctions.IXA_MOL_CreateAtom(logger, nativeMol);
  IxaFunctions.IXA_MOL_SetAtomX(logger, nativeMol, nativeAtom, 543.21);
  var x = IxaFunctions.IXA_MOL_GetAtomX(logger, nativeMol, nativeAtom);
  IxaFunctions.IXA_MOL_Destroy(logger, nativeMol);
  IxaFunctions.IXA_STATUS_Destroy(logger);

So it turns out that JNA and WASM are completely compatible, and there should be no need for any significant Java coding changes to enable anything JNA-InChI does in both Java and JavaScript.

Basically, anything that looks like this:

static native void IXA_MOL_Destroy(Pointer hStatus, Pointer hMolecule);

can be expressed in JavaScript as:

IXA_MOL_Destroy = module.cwrap("IXA_MOL_Destroy", null, ["number", "number"]);

Pretty much as simple as that. No changes to any C code; just some additional exported methods in the makefile for the WASM and a list of these declarations. It could easily be fully automated.

Interesting?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions