[quickjs-devel] Re: Export JS_ToQuotedString()

  • From: Connor Nolan <connor24nolan@xxxxxxxx>
  • To: "quickjs-devel@xxxxxxxxxxxxx" <quickjs-devel@xxxxxxxxxxxxx>
  • Date: Sun, 11 Aug 2019 22:48:39 +0000

Here are two patches I made, one exports JS_ToQuotedString(), and another moves 
most code from js_function_bind(), to its own function and exports it 
(JS_BindFunction()).

________________________________
From: quickjs-devel-bounce@xxxxxxxxxxxxx <quickjs-devel-bounce@xxxxxxxxxxxxx> 
on behalf of Charlie Gordon <quickjs@xxxxxxxxxxx>
Sent: Saturday, August 10, 2019 12:16 PM
To: quickjs-devel@xxxxxxxxxxxxx <quickjs-devel@xxxxxxxxxxxxx>
Subject: [quickjs-devel] Re: Export JS_ToQuotedString()

On 10 Aug 2019, at 20:51, Connor Nolan 
<connor24nolan@xxxxxxxx<mailto:connor24nolan@xxxxxxxx>> wrote:
It would be nice if you could create a quoted version of a string, without 
having to rely on "__quote()", it would also be nice if js_function_bind was 
able to be called from C without having to call a JavaScript function "bind()".

JS_ToQuotedString seems easy to export, the API is quite straight forward.

In case you wonder, I hesitated to make the Javascript binding a method of 
String named toSource() as is available in Firefox, but not many engines 
support this only for strings would have been misleading, We even considered 
removing it, but it is used un json formatting and handy for displaying values 
in the REPL.

js_bind_function() is more cumbersome to call directly from C, but why not, 
except for the naming scheme...

What is your use case?

Chqrlie

Other related posts: