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)
/
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)
North America
Europe, Middle East and Africa
Asia Pacific