-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix document for returnType and argTypes of cwrap #23981
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
base: main
Are you sure you want to change the base?
Fix document for returnType and argTypes of cwrap #23981
Conversation
@@ -114,8 +114,8 @@ Calling compiled C functions from JavaScript | |||
my_func(12) | |||
|
|||
:param ident: The name of the C function to be called. | |||
:param returnType: The return type of the function. This can be ``"number"``, ``"string"`` or ``"array"``, which correspond to the appropriate JavaScript types (use ``"number"`` for any C pointer, and ``"array"`` for JavaScript arrays and typed arrays; note that arrays are 8-bit), or for a void function it can be ``null`` (note: the JavaScript ``null`` value, not a string containing the word "null"). | |||
:param argTypes: An array of the types of arguments for the function (if there are no arguments, this can be omitted). Types are as in ``returnType``, except that ``array`` is not supported as there is no way for us to know the length of the array). | |||
:param returnType: The return type of the function. This can be ``"number"`` or ``"string"``, which correspond to the appropriate JavaScript types (use ``"number"`` for any C pointer), or for a void function it can be ``null`` (note: the JavaScript ``null`` value, not a string containing the word "null"). ``array`` is not supported as there is no way for us to know the length of the array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code it looks like we support "string", "pointer" and "boolean".
I'm not sure we need to spell out where why array
is not a valid return type, or rather I'm not sure exactly what the rational is so maybe better to leave it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for array
was simply carried over from what originally existed, so I don't think it's essential, and it can be removed.
That aside, the following description for ":param argTypes:" has disappeared; is this acceptable? I added array
to the list of acceptable argument types.
:param argTypes: An array of the types of arguments for the function (if there are no arguments, this can be omitted). Types can be ``"number"``, ``"string"`` or ``"array"``, which correspond to the appropriate JavaScript types (use ``"number"`` for any C pointer, and ``"array"`` for JavaScript arrays and typed arrays; note that arrays are 8-bit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should still have some argTypes
documentation. I did't realize the rational was part of the original docs here.
cwrap
function callsccall
, which does not accept "array" as a return type.Consequently, the current documentation for cwrap's returnType and argTypes parameters is inaccurate, and this PR updates it accordingly.