Answered by:
Platform::Array<unsigned char>^ and Platform::String^ have same signature to JS?

Question
-
Given this class:
public ref class Foo sealed { public: Foo(Platform::String^ filePath); Foo(Platform::Array<unsigned char>^ buffer); }
The call in JavaScript
Foo('some file path')
and
Foo([1,2,3])
result in ctor Foo(Platform::String^ pdfFile); being called. How can I force JS to call the array ctor when I am using an array?
Thanks!- Edited by phil_ke Wednesday, March 14, 2012 1:23 PM
Wednesday, March 14, 2012 1:23 PM
Answers
-
This probably does not help but, I did file a bug on this issue.
The response was: functions need to have different arities to be overloaded and be seen from JS.
and since I had to look up arities(http://en.wikipedia.org/wiki/Arities).... it is the number of arguments or operands that the function takes
Thanks
Derek- Marked as answer by DavidLambMicrosoft employee, Moderator Wednesday, July 11, 2012 6:42 PM
Thursday, June 7, 2012 11:18 PM
All replies
-
No, the first letter should be lowercase.
If your JavaScript code doesn't seem to recognize the public properties or methods in the component, make sure that in JavaScript you are using camel casing. For example, the ComputeResult C++ method must be referenced as computeResult in JavaScript.
From:http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh755833(v=vs.110).aspx
Best regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Thursday, March 15, 2012 7:59 AM -
As you can see Jesse, the first letter has to be uppercase since this is the ctor method I am calling. Any other ideas?
My JS recognizes the public Foo ctor it just always calls the String^ Variant even when called with a byte array as I described.
Thursday, March 15, 2012 8:53 AM -
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh441569(v=vs.110).aspx
Do not know if it works on ctor overloading..
[Windows::Foundation::Metadata::Overload("FooArray")]
Foo(Platform::Array<unsigned char>^ buffer);
[Windows::Foundation::Metadata::Overload("FooString")]
Foo(Platform::String^ filePath);- Proposed as answer by James Dailey - MSFTMicrosoft employee, Moderator Friday, May 11, 2012 11:17 PM
Thursday, May 10, 2012 10:54 AM -
Hello phil,
Did adewang82's post answer your question? It looks to me like it should. If you still have questions please let us know.
-James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Friday, May 11, 2012 1:15 AMModerator -
Thanks, I will try that out! :) Although I found a workaround using static functions already.Friday, May 11, 2012 1:38 PM
-
No, unfortunately it does not work. The String method is called everytime.Friday, May 11, 2012 3:09 PM
-
did you call it through FooArray or Foo?Saturday, May 12, 2012 1:29 AM
-
Ah, right, I did not di that. Will try again.Saturday, May 12, 2012 8:56 AM
-
This probably does not help but, I did file a bug on this issue.
The response was: functions need to have different arities to be overloaded and be seen from JS.
and since I had to look up arities(http://en.wikipedia.org/wiki/Arities).... it is the number of arguments or operands that the function takes
Thanks
Derek- Marked as answer by DavidLambMicrosoft employee, Moderator Wednesday, July 11, 2012 6:42 PM
Thursday, June 7, 2012 11:18 PM