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

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

  • mercoledì 14 marzo 2012 13:23
     
      Contiene codice

    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!


    • Modificato phil_ke mercoledì 14 marzo 2012 13:23
    •  

Tutte le risposte

  • giovedì 15 marzo 2012 07:59
    Moderatore
     
     

    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,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

  • giovedì 15 marzo 2012 08:53
     
     

    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.

  • giovedì 10 maggio 2012 10:54
     
     Risposta suggerita

    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);

  • venerdì 11 maggio 2012 01:15
    Moderatore
     
     

    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/

  • venerdì 11 maggio 2012 13:38
     
     
    Thanks, I will try that out! :) Although I found a workaround using static functions already.
  • venerdì 11 maggio 2012 15:09
     
     
    No, unfortunately it does not work. The String method is called everytime.
  • sabato 12 maggio 2012 01:29
     
     
    did you call it through FooArray or Foo?
  • sabato 12 maggio 2012 08:56
     
     
    Ah, right, I did not di that. Will try again.
  • giovedì 7 giugno 2012 23:18
     
     Con risposta

    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