[quickjs-devel] Re: How to QuickJS C API to new Function with js script code ?

  • From: "Sam Chang" <dmarc-noreply@xxxxxxxxxxxxx> (Redacted sender "sam.chang" for DMARC)
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Thu, 1 Aug 2019 12:10:12 +0800

I think you are looking for JS_Call

Implementation 1:
https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOS/Classes/QJSContext.m#L127
 
<https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOS/Classes/QJSContext.m#L127>

TestCase 1:
https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOSTests/QuickJS_iOSTests.m#L194
 
<https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOSTests/QuickJS_iOSTests.m#L194>


Implementation 2:
https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOS/Classes/QJSContext.m#L220
 
<https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOS/Classes/QJSContext.m#L220>

TestCase 2:
https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOSTests/QuickJS_iOSTests.m#L243
 
<https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOSTests/QuickJS_iOSTests.m#L243>


On Aug 1, 2019, at 12:00 PM, wenyang wu <wenyoung.wu@xxxxxxxxx> wrote:

Hi,

   JS:

let func = new Function ([arg1, arg2, ...argN], functionBody);

     I want to use QuickJS C API to new a Function with js script code.
But I don't  know which API is suitable


Regards,
Young


Other related posts: