Skip navigation
Currently Being Moderated

The C-level API

Aug 14, 2012 2:05 AM

 
Replies
  • Currently Being Moderated
    Aug 14, 2012 2:05 AM   in reply to Community Help

    the fourth param of JS_ExecuteScript() function should mean the length of the string, not in bytes.

     

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 20, 2012 11:08 AM   in reply to ScreenNameIsWhat

    Thanks for the tip. This will be fixed in the next release of Flash Pro docs.

     

    Regards,

    Randy Nielsen

    Senior Content and Community Manager

    Adobe

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 10, 2013 3:16 PM   in reply to Community Help

    JS_ExecuteScript is implemented incorrectly. The conversion:

    (LPCTSTR)__FILE__

    is incorrect.

    First off __FILE__ generates C-string constant, not a unicode one. Then if the application is a unicode one, LPCTSTR stands for LPCWSTR which stands for unsigned short*.

     

    Converting char* (__FILE__) to unsigned short* is absolutely wrong.

    In the case of a non-unicode application, the LPCTSTR is translated to LPCSTR which is a char, but the function needs unsigned short.

    The way to do this is:

    (unsigned short *) T(_FILE__)

     

    I am not sure whether _T(...) will convert __FILE__ to unicode in the case of an ANSI application - I presume not.

     

    I've made a sample Unicode C-level extension dll in which I added and registered a function that calls JS_ExecuteScript. I called the dll's function from a test jsfl command.

     

    I had some error with the script that I tried to call with JS_ExecuteScript, and Flash warned me about an error in my script. The file name was displayed in Chinese letters

     

    because of the wrong conversion from char* to unsigned short*.

     

     

    #define JS_ExecuteScript(c, o, s, z, r) \

        (mmEnv.executeScript  ? (*(mmEnv.executeScript))(c, o, s, z, (unsigned short *) T(_FILE__), \

            __LINE__, r) : JS_FALSE)

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 11, 2013 5:40 AM   in reply to Community Help

    /

    • unsigned short *JS_ValueToString(JSContext *cx, jsval v, unsigned int *pLength) */

    #define JS_ValueToString(c, v, l) \

        (mmEnv.valueToString  ? (*(mmEnv.valueToString))(c, v, l) : (char *)0)

     

    Should be:

    /* unsigned short *JS_ValueToString(JSContext *cx, jsval v, unsigned int *pLength) */

    #define JS_ValueToString(c, v, l) \

        (mmEnv.valueToString  ? (*(mmEnv.valueToString))(c, v, l) : (unsigned short *)0)

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points