Re: error: incomplete type ‘JSLinearString ’ used in nested name specifier

Steve Fink <[email protected]> Sun, 31 May 2020 19:28:22 -0700
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
On 5/30/20 11:39 PM, Kram Jordy wrote:
> On Saturday, 30 May 2020 22:55:52 UTC+1, Tom Schuster  wrote:
>> 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.
> Hi Tom. Yes I'll make sure I use this API function. I've not actually posted any of my code, so if there are any bugs in the snippets, then they are also bugs in the javascript shell js.cpp.

That's a natural expectation, but unfortunately shell/js.cpp is *not* a 
SpiderMonkey embedding, but is rather an internal application that has 
access to more APIs than would an embedding that is only linking with mozjs.


>
>>> 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)
> Yes that's the one. Like it or not, this is the *only* up-to-date piece of code that spidermonkey embedders can look to for examples that I'm aware of. It would be great if the spidermonkey team could do regular code reviews on it to ensure it reflects the current best practices and idioms.

Sorry, I should have mentioned earlier: you should look at 
https://github.com/mozilla-spidermonkey/spidermonkey-embedding-examples 
<https://github.com/mozilla-spidermonkey/spidermonkey-embedding-examples>