saschanaz / uwp-type-generator

Type definition file generator for UWP API
MIT License
2 stars 0 forks source link

IVector<> doesn't accept array #8

Open RReverser opened 8 years ago

RReverser commented 8 years ago

I'm trying to use fileSavePicker.fileTypeChoices.insert("Plain Text", [".txt"]) as shown in https://msdn.microsoft.com/library/windows/apps/br207871, but getting

Argument of type 'string[]' is not assignable to parameter of type 'IVector'.

Looks like those types are not mapped correctly.

saschanaz commented 8 years ago

Right, at least some methods that receive IVector or IVectorView also receives normal array and we should map this properly. Unfortunately I cannot know which ones do and which ones don't. I currently can only hope every methods consistently do.

Should I allow every functions that receive IVector/IVectorView to also receive normal arrays?

RReverser commented 8 years ago

Should I allow every functions that receive IVector/IVectorView to also receive normal arrays?

I don't really know :/ Are you aware of any exclusions?

saschanaz commented 8 years ago

Are you aware of any exclusions?

No. It seems I should just introduce the change and see if there are any problems as even the MSDN documents have no single comment about JS arrays :/

RReverser commented 8 years ago

Yeah, I also looked through https://msdn.microsoft.com/en-us/library/hh710232%28v=vs.94%29.aspx but it doesn't clarify much.

saschanaz commented 8 years ago

A JavaScript value is converted to a Windows Runtime array as follows: If the value is null or undefined, it is converted to a native null. If its internal [[Class]] property is “Array”, it is copied to a native array and a reference to this array is passed. If it is a converted array, as described previously, the underlying native array is passed. Note: Passing a JavaScript array value to a Windows Runtime method causes a full copy of the array.

This does not explicitly say that every WinRT method receives JS array but I think it implies so. Thank you for the link :+1:

RReverser commented 8 years ago

@SaschaNaz If I understand that text correctly, on Windows Runtime side array from JS is copied to pretty much the same as CLR Array. If that assumption is correct, all the interfaces that CLR Array is compatible with, should be compatible with JS Array as well (and those that are not, won't be compatible, too).

saschanaz commented 8 years ago

Long time no news, I think I will start to fix this in a week.

7/11/2016: Aww... Sorry, I've been working on other things.

naf456 commented 8 years ago

Use Windows.Storage.Pickers.FileExtensionVector class? https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.fileextensionvector.aspx

It implements IVector