Re: error: incomplete type ‘JSLinearString’ used in nested name specifier
Tom Schuster <[email protected]> Sat, 30 May 2020 23:55:06 +0200
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <CAN7ST63hGcYpor4Z=SheWF_V=Ue4qdAyR7qOtBKPOnTauoUn1Q@mail.gmail.com> |
You should only use the first code snippet using JS_EnsureLinearString. Like Steve said it would be a good idea to add those tracing kinds, because right now you strings seem to be unrooted. Most (all?) of the public API is either in jsapi.h or in of the header files in public/ folder. > I was following the examples in the js-shell, however, they do the same thing about 4 different ways, so I was rather confused! I assume you are talking about: https://searchfox.org/mozilla-central/source/js/src/shell/js.cpp ? In that case you really should not necessarily be using this file as a template. The shell is considered part of the JavaScript engine proper and uses many internal APIs. (Out of necessity really, many APIs that need testing are only internal) Of course our public API usually only has stuff that is actually required by Gecko/Firefox, so it is likely that you might be running into a situation where a public API is missing. In that case it's best to report a bug. https://github.com/mozilla-spidermonkey/spidermonkey-embedding-examples is a good place to find examples of SpiderMonkey's public API. Aside: The static version of ensureLinear is silly and should just be removed .. There seems to be only a single user: https://searchfox.org/mozilla-central/rev/d9d492eda787a6eda66016e6f8398ee759f7bc25/js/src/shell/js.cpp#9307 Good luck, Tom On Sat, May 30, 2020 at 11:45 PM Kram Jordy <[email protected]> wrote: > > Thanks for your insights Steve, I've filed a bug report as suggested, #1642154. > > I was following the examples in the js-shell, however, they do the same thing about 4 different ways, so I was rather confused! > > > JSString* str = argv[0].toString(); > JSLinearString* linearStr = JS_EnsureLinearString(cx, str); > if (!linearStr) { > return false; > } > > ---- > > RootedLinearString linearFormat( > cx, optionFormat.toString()->ensureLinear(cx)); > if (!linearFormat) { > return false; > } > > ---- > > Rooted<JSLinearString*> linear(cx, str->ensureLinear(cx)); > if (!linear) { > return false; > } > > ---- > > if (!JSString::ensureLinear(cx, v.toString())) { > return false; > } > RootedLinearString input(cx, &v.toString()->asLinear()); > _______________________________________________ > dev-tech-js-engine mailing list > [email protected] > https://lists.mozilla.org/listinfo/dev-tech-js-engine