Returning nested arrays from host object #2818
Unanswered
jaredkrinke
asked this question in
Q&A
Replies: 1 comment
-
Interestingly, option 1 above is how nested arrays are marshalled into my C++ code, but they don't get marshalled back out correctly. Seems like either I misinterpreted the docs or there's a bug. Here's my function: HRESULT Test([in] VARIANT vin, [out, retval] VARIANT* vout); And implementation is basically just VariantCopy: STDMETHODIMP Steam::Test(VARIANT vin, VARIANT* vout) {
VariantInit(vout);
VariantCopy(vout, &vin);
return S_OK;
} From JavaScript, if I call the function on my host object: chrome.webview.hostObjects.sync.h.Test([[1, "two"], ["three", 4]]) The result is: [[null, null], [null, null]] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Does anyone have a working (C++) example of returning nested arrays from a host object?
The docs (side note: only the .NET docs have any details; the Win32 version is basically just a function prototype) say:
But I've tried a few different approaches and can't get it to work. I'm returning (via an out param) a VARIANT, and I've tried:
[[null, null], [null, null]]
)null
)It's odd that I can get the nested arrays to work, but then even trivial values (e.g. VT_I4) end up as null on the JavaScript side.
I can work around this by constructing a big JSON blob, but I'd like to avoid string manipulation/escaping as much as possible.
Edit: I should add that I verified in the Visual Studio C++ debugger that I'm returning a SAFEARRAY of SAFEARRAY, and that the innermost items are set correctly (e.g. vt = VT_I4 and lVal = 123). The issue I'm having is related to how the data is marshaled back to the JavaScript side.
Beta Was this translation helpful? Give feedback.
All reactions