NPAPI:ArrayDictAndBinary: Difference between revisions

Refactored the overview to hopefully be more readable
(Proposal for three new NPVariant Types: NPArray, NPDictionary, and NPByteArray)
 
(Refactored the overview to hopefully be more readable)
Line 13: Line 13:
The use of javascript has dramatically improved and changed over the years since NPRuntime was created, but the data types supported by NPRuntime have remained about the same, supporting only one non-primitive type and without any way to return binary data to the page. In order for a plugin to interact with javascript in a natural way and fully utilize all features of a modern browser there are three datatypes that should be added to the NPVariant structure.
The use of javascript has dramatically improved and changed over the years since NPRuntime was created, but the data types supported by NPRuntime have remained about the same, supporting only one non-primitive type and without any way to return binary data to the page. In order for a plugin to interact with javascript in a natural way and fully utilize all features of a modern browser there are three datatypes that should be added to the NPVariant structure.


With the advent of the HTML5 Canvas and other related technologies there is now a strong use case for passing binary data into Javascript. The specific data structure that this should end up in is not entirely clear at this time; options may include a ImageData array, a Uint8Array, etc, but may even differ somewhat depending on the browser; this should be avoided if possible, so perhaps the best option would be to convert it to a standard javascript array but with the byte data in each element. This would at least provide a reasonable method to send the data to javascript, and perhaps the specification could be somewhat loose as to the exact type used by the javascript interpreter on the other side? (TODO: Resolve this question) A NPByteArray type will be introduced to resolve this issue.
== Binary data ==
 
With the introduction of the HTML5 Canvas and other related technologies there is now a strong use case for passing binary data into Javascript. While there doesn't seem to be a clear choice for what type of data structure in javascript should handle this, the options seem to all have a fairly similar interface at least for querying the data. If a datatype were added to NPRuntime to support a binary array of data, each browser and javascript engine could implement the specifics using whatever data type is most appropriate in their environment, with the most basic option being a javascript array of integers.
 
== Array and dictionary (key/value) data ==


An even more pressing and more common need is the need to return javascript arrays or objects that act as a key/value dictionary. Current solutions exist:
An even more pressing and more common need is the need to return javascript arrays or objects that act as a key/value dictionary. Current solutions exist:
4

edits