|
Rank: Newbie Groups: Member
Joined: 10/18/2021 Posts: 3
|
with technique like ObjectForScripting we can call C functions passing parameters like string or int; but there is a way to pass also ArrayBuffer of SharedArrayBuffer ? Thank You.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,201
|
Hi,
You could pass them but you would be actually passing a "handle" of the object. Any access to the object itself would still need to go back to the JavaScript side and any derived objects (such as a view of the ArrayBuffer) would still live on the JavaScript side. So if you just need to "reference" the object, this would be fine. However if you are really interested in the content of the object (such as all the raw bytes), then passing the ArrayBuffer object would have no use to you because the actual data is not really passed over.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 10/18/2021 Posts: 3
|
eo_support wrote:Hi,
...if you are really interested in the content of the object (such as all the raw bytes), then passing the ArrayBuffer object would have no use to you because the actual data is not really passed over.
would be fine and VERY interesting to get the pointer of ArrayBuffer raw data ! Thank you for your reply CAP
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,201
|
You can't. The only way for you to get data through is to make a copy of it. For example, you can base64 encode the data into a string on the JavaScript side, pass the string from the JavaScript side to the C# side, then base64 decode it on the C# side.
It is not possible for you to get pointer of the raw data because these are two different "world". One is the JavaScript World lives inside the browser engine process, another one is your .NET code lives inside your own process. You can only have references or copy, you can not have direct pointer between the two.
|
|
Rank: Newbie Groups: Member
Joined: 10/18/2021 Posts: 3
|
eo_support wrote:You can't. The only way for you to get data through is to make a copy of it. For example, you can base64 encode the data into a string on the JavaScript side, pass the string from the JavaScript side to the C# side, then base64 decode it on the C# side.
It is not possible for you to get pointer of the raw data because these are two different "world". One is the JavaScript World lives inside the browser engine process, another one is your .NET code lives inside your own process. You can only have references or copy, you can not have direct pointer between the two. What about SharedArrayPointer and/or reverse the approach that is create the arrayBuffer inside C .. (I apologize for my insistence, but it would be really useful to be able to do it, it would open up new application spaces) Thank you
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,201
|
You still can't. SharedArrayBuffer is designed to be shared between different components between the browser engine (such as a page and a background worker) and it is still managed by the browser engine. It is not meant to leave the browser engine. Allowing outside access would have the potential of corrupting internal data maintained by the browser engine since the browser engine does not expect anybody else but itself to touch those data.
The simple absolute rule here is: Nobody leaves the world they live in. This applies to everybody. JavaScript objects do not leave JavaScript world. .NET objects do not leave .NET world. Thinking anything otherwise is a deadend.
|
|