microsoft / Chakra-Samples

Repository for Chakra JavaScript engine related samples.
MIT License
216 stars 84 forks source link

[JsCreateExternalArrayBuffer] in native.cs returns bool, should be JavaScriptValue #62

Closed JohnMasen closed 7 years ago

JohnMasen commented 7 years ago

Native.cs

internal static extern JavaScriptErrorCode JsCreateExternalArrayBuffer(IntPtr data, uint byteLength, JavaScriptObjectFinalizeCallback finalizeCallback, IntPtr callbackState, out bool result);

Document

STDAPI_(JsErrorCode) JsCreateExternalArrayBuffer(
  _Pre_maybenull_ _Pre_writable_byte_size_(byteLength) void *data,
  _In_ unsigned int byteLength,
  _In_opt_ JsFinalizeCallback finalizeCallback,
  _In_opt_ void *callbackState,
  _Out_ JsValueRef *result
);
liminzhu commented 7 years ago

Thanks for the opening the issue @JohnMasen! The out type is intentional as PInvoke can marshall the type. See JsHasProperty for another example.

JohnMasen commented 7 years ago

JsCreateExternalArrayBuffer is supposed to create an external ArrayBuffer, expected to return a Javascriptvalue instead of a bool flag. I've modified the method signature to return Javascriptvalue and now it works. please correct the wrapper to avoid confuse others. here's the modified version internal static extern JavaScriptErrorCode JsCreateExternalArrayBuffer(IntPtr data, uint byteLength, JavaScriptObjectFinalizeCallback finalizeCallback, IntPtr callbackState, out JavaScriptValue obj);

liminzhu commented 7 years ago

Oh you're absolutely right, I misread it for something else. Just sent a fix https://github.com/Microsoft/Chakra-Samples/commit/24fb1f8cc1e8968de57269f59ab11467938d022e.