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

[email protected] Thu, 30 Apr 2020 22:20:02 -0700 (PDT)
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
Kannan

I tried with RootedString as well.Also JS_EncodeStringToUTF8 does not allow(compile error) assignment to UniqueChars type but it did allow assignment to char * but in that case value still came as undefined. I am surprised how your example allow assignment . My compiler is clang.

JS::CallArgs args = CallArgsFromVp(argc, argv);
    for(int i=0; i<args.length(); i++) {
        JS::RootedString str(cx, JS::ToString(cx, args[i]));
        if (!str) {
          return false;
        }
       char *bytes = JS_EncodeStringToUTF8(cx, str);;
        if (!bytes) {
          return false;
        }
        print_error("DEBUG: doit value : %s\n",bytes); //Output -> DEBUG: doit value : undefined
    }