Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jassoc API to directly associate a name to A #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhihaoy
Copy link

@zhihaoy zhihaoy commented Feb 8, 2021

Abstract

This PR proposes a new DLL API, Jassoc, which allows binding an object of A directly to a name in J.

Motivation

J ships j.dll and libj.so with different capabilities if the former is built with OLECOM. Only in COM interface, J.dll is able to put structural data in J using an array of boxes. In COM, the structural data is a multi-dimensional array of VARIANT. But to the other language bindings, this is not possible, because JSetM doesn't allow it. This is different from JGetM which does allow accessing arrays of A from the DLL interface.

In order to exchange Python's tuple or np.array of Object with J, we need to put arrays of A into J using the non-COM, dynamic library interface.

DIscussion

One option might be adding this functionality to the existing JSetM. But JSetM assumes that we are not copying data from A back to J. Meanwhile,

  1. Processing structural data ends up having recursive calls, and the natural outcome of that call is A.
  2. We don't want to allocate an array of A in a foreign language's heap just for the purpose of fitting into JSetM's interface, because no foreign language can make use of A.

In a word, we want to allocate A on J's heap using Jga, update its content, and give that array a name in J.

Doing so has an extra desired property. In the past, a foreign language must provide data in int64_t or double, because JSetM won't be able to copy from a contiguous memory of int32_t or float. But if we can assign A back to J, we can form A first, and do the copying outside. This copy doesn't need to be memcpy.

Implementation

The patch originates from a change on an older branch that has no j903 multithreaded areas. That change worked well, but the patch in this PR is rebased accordingly and provided as-is. We haven't tested it because J upstream is not CMake-enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant