Re: JS::CallArgs - Arguments are not being parsed in C++

Kannan Vijayan <[email protected]> Fri, 1 May 2020 00:44:44 -0400
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <CAA2eH6daUxhtK28d4G-EfRTeY77hTQgUndAdX97UT7RYRvGjvw@mail.gmail.com>
Hi,

I haven't run your code directly, but I noticed a couple of things that are
off here.

For one: You want to use JS::RootedString instead of a raw JSString* to
hold the string pointer.  Also, I'm not sure where you're able to call a
plain JS_EncodeString, but I think you should be using
JS_EncodeStringToUTF8, and you also want to hold the result of the
JS_EncodeStringToUTF8 in a JS::UniqueChars instead of a raw char pointer.
Please consider this example from the shell code to use as a guide:

https://searchfox.org/mozilla-central/rev/7fd1c1c34923ece7ad8c822bee062dd0491d64dc/js/src/shell/js.cpp#2785

Hope that helps.
Kannan



On Fri, May 1, 2020 at 12:10 AM <[email protected]> wrote:

> James, I tried that but my argument does not pass isString check.Further
> diagnosis  pointed to me that isNumber evaluation becomes true.So argument
> is coming as Number.This is even more crazier that passed argument is a
> String value.Although if I change number of arguments then count comes
> correct but data type is completely incorrect.Getting out of ideas here.
> _______________________________________________
> dev-tech-js-engine mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>