javascriptcore

Search:
Group by:

Low-level Nim bindings for JavaScriptCore, Apple's JavaScript engine.

C names are preserved verbatim so upstream code stays greppable. Uses the JavaScriptCore framework on macOS.

Basic example:

import javascriptcore

withGlobalContext(ctx):
  var ex: JSValueRef = nil
  let res = evalScript(ctx, "1 + 2", exception = ex)
  assert ex == nil
  var ex2: JSValueRef = nil
  assert JSValueToNumber(ctx, res, addr ex2) == 3.0

The raw API (JSEvaluateScript, JSObjectMakeFunctionWithCallback, ...) returns exactly what C returns, including nil on failure: always check the exception out-param. helpers adds newJSString, $, evalScript and withGlobalContext on top.

Define jscStatic (or jscNoPkgConfig) to skip the automatic link flags and supply your own. Define jscStaticLib with the path to a custom static libjavascriptcore archive to link it directly (jscIncludeDir optionally points at its headers).

Consts

jscIncludeDir {.strdefine.} = ""
Extra C include dir for the JavaScriptCore headers, e.g. -d:jscIncludeDir=/opt/jsc/include. Applies in every link mode.
jscStaticLib {.strdefine.} = ""
Path to a custom static JavaScriptCore archive, e.g. -d:jscStaticLib=/opt/jsc/lib/libjavascriptcore.a. Takes precedence over every automatic link mode below. Extra native dependencies of your build (ICU, etc.) still need their own --passL.

Exports

JSCheckScriptSyntax, JSClassRef, JSContextGroupRef, JSContextRef, JSEvaluateScript, JSGarbageCollect, JSGlobalContextRef, JSObjectRef, JSPropertyNameAccumulatorRef, JSPropertyNameArrayRef, JSStringRef, JSTypedArrayBytesDeallocator, JSValueRef, OpaqueJSClass, OpaqueJSContext, OpaqueJSContextGroup, OpaqueJSPropertyNameAccumulator, OpaqueJSPropertyNameArray, OpaqueJSString, OpaqueJSValue, jscHeader, JSChar, JSCheckScriptSyntax, JSClassRef, JSContextGroupRef, JSContextRef, JSEvaluateScript, JSGarbageCollect, JSGlobalContextRef, JSObjectRef, JSPropertyNameAccumulatorRef, JSPropertyNameArrayRef, JSStringCreateWithCharacters, JSStringCreateWithUTF8CString, JSStringGetCharactersPtr, JSStringGetLength, JSStringGetMaximumUTF8CStringSize, JSStringGetUTF8CString, JSStringIsEqual, JSStringIsEqualToUTF8CString, JSStringRef, JSStringRelease, JSStringRetain, JSTypedArrayBytesDeallocator, JSValueRef, OpaqueJSClass, OpaqueJSContext, OpaqueJSContextGroup, OpaqueJSPropertyNameAccumulator, OpaqueJSPropertyNameArray, OpaqueJSString, OpaqueJSValue, jscHeader, JSCheckScriptSyntax, JSClassRef, JSContextGetGlobalContext, JSContextGetGlobalObject, JSContextGetGroup, JSContextGroupCreate, JSContextGroupRef, JSContextGroupRelease, JSContextGroupRetain, JSContextRef, JSEvaluateScript, JSGarbageCollect, JSGlobalContextCopyName, JSGlobalContextCreate, JSGlobalContextCreateInGroup, JSGlobalContextIsInspectable, JSGlobalContextRef, JSGlobalContextRelease, JSGlobalContextRetain, JSGlobalContextSetInspectable, JSGlobalContextSetName, JSObjectRef, JSPropertyNameAccumulatorRef, JSPropertyNameArrayRef, JSStringRef, JSTypedArrayBytesDeallocator, JSValueRef, OpaqueJSClass, OpaqueJSContext, OpaqueJSContextGroup, OpaqueJSPropertyNameAccumulator, OpaqueJSPropertyNameArray, OpaqueJSString, OpaqueJSValue, jscHeader, JSBigIntCreateWithDouble, JSBigIntCreateWithInt64, JSBigIntCreateWithString, JSBigIntCreateWithUInt64, JSCheckScriptSyntax, JSClassRef, JSContextGroupRef, JSContextRef, JSEvaluateScript, JSGarbageCollect, JSGlobalContextRef, JSObjectRef, JSPropertyNameAccumulatorRef, JSPropertyNameArrayRef, JSRelationCondition, JSStringRef, JSType, JSTypedArrayBytesDeallocator, JSTypedArrayType, JSValueCompare, JSValueCompareDouble, JSValueCompareInt64, JSValueCompareUInt64, JSValueCreateJSONString, JSValueGetType, JSValueGetTypedArrayType, JSValueIsArray, JSValueIsBigInt, JSValueIsBoolean, JSValueIsDate, JSValueIsEqual, JSValueIsInstanceOfConstructor, JSValueIsNull, JSValueIsNumber, JSValueIsObject, JSValueIsObjectOfClass, JSValueIsStrictEqual, JSValueIsString, JSValueIsSymbol, JSValueIsUndefined, JSValueMakeBoolean, JSValueMakeFromJSONString, JSValueMakeNull, JSValueMakeNumber, JSValueMakeString, JSValueMakeSymbol, JSValueMakeUndefined, JSValueProtect, JSValueRef, JSValueToBoolean, JSValueToInt32, JSValueToInt64, JSValueToNumber, JSValueToObject, JSValueToStringCopy, JSValueToUInt32, JSValueToUInt64, JSValueUnprotect, OpaqueJSClass, OpaqueJSContext, OpaqueJSContextGroup, OpaqueJSPropertyNameAccumulator, OpaqueJSPropertyNameArray, OpaqueJSString, OpaqueJSValue, jscHeader, JSBigIntCreateWithDouble, JSBigIntCreateWithInt64, JSBigIntCreateWithString, JSBigIntCreateWithUInt64, JSCheckScriptSyntax, JSClassAttributes, JSClassCreate, JSClassDefinition, JSClassRef, JSClassRelease, JSClassRetain, JSContextGroupRef, JSContextRef, JSEvaluateScript, JSGarbageCollect, JSGlobalContextRef, JSObjectCallAsConstructor, JSObjectCallAsConstructorCallback, JSObjectCallAsFunction, JSObjectCallAsFunctionCallback, JSObjectConvertToTypeCallback, JSObjectCopyPropertyNames, JSObjectDeleteProperty, JSObjectDeletePropertyCallback, JSObjectDeletePropertyForKey, JSObjectFinalizeCallback, JSObjectGetPrivate, JSObjectGetProperty, JSObjectGetPropertyAtIndex, JSObjectGetPropertyCallback, JSObjectGetPropertyForKey, JSObjectGetPropertyNamesCallback, JSObjectGetPrototype, JSObjectHasInstanceCallback, JSObjectHasProperty, JSObjectHasPropertyCallback, JSObjectHasPropertyForKey, JSObjectInitializeCallback, JSObjectIsConstructor, JSObjectIsFunction, JSObjectMake, JSObjectMakeArray, JSObjectMakeConstructor, JSObjectMakeDate, JSObjectMakeDeferredPromise, JSObjectMakeError, JSObjectMakeFunction, JSObjectMakeFunctionWithCallback, JSObjectMakeRegExp, JSObjectRef, JSObjectSetPrivate, JSObjectSetProperty, JSObjectSetPropertyAtIndex, JSObjectSetPropertyCallback, JSObjectSetPropertyForKey, JSObjectSetPrototype, JSPropertyAttributes, JSPropertyNameAccumulatorAddName, JSPropertyNameAccumulatorRef, JSPropertyNameArrayGetCount, JSPropertyNameArrayGetNameAtIndex, JSPropertyNameArrayRef, JSPropertyNameArrayRelease, JSPropertyNameArrayRetain, JSRelationCondition, JSStaticFunction, JSStaticValue, JSStringRef, JSType, JSTypedArrayBytesDeallocator, JSTypedArrayType, JSValueCompare, JSValueCompareDouble, JSValueCompareInt64, JSValueCompareUInt64, JSValueCreateJSONString, JSValueGetType, JSValueGetTypedArrayType, JSValueIsArray, JSValueIsBigInt, JSValueIsBoolean, JSValueIsDate, JSValueIsEqual, JSValueIsInstanceOfConstructor, JSValueIsNull, JSValueIsNumber, JSValueIsObject, JSValueIsObjectOfClass, JSValueIsStrictEqual, JSValueIsString, JSValueIsSymbol, JSValueIsUndefined, JSValueMakeBoolean, JSValueMakeFromJSONString, JSValueMakeNull, JSValueMakeNumber, JSValueMakeString, JSValueMakeSymbol, JSValueMakeUndefined, JSValueProtect, JSValueRef, JSValueToBoolean, JSValueToInt32, JSValueToInt64, JSValueToNumber, JSValueToObject, JSValueToStringCopy, JSValueToUInt32, JSValueToUInt64, JSValueUnprotect, OpaqueJSClass, OpaqueJSContext, OpaqueJSContextGroup, OpaqueJSPropertyNameAccumulator, OpaqueJSPropertyNameArray, OpaqueJSString, OpaqueJSValue, jscHeader, kJSClassAttributeNoAutomaticPrototype, kJSClassAttributeNone, kJSClassDefinitionEmpty, kJSPropertyAttributeDontDelete, kJSPropertyAttributeDontEnum, kJSPropertyAttributeNone, kJSPropertyAttributeReadOnly, JSBigIntCreateWithDouble, JSBigIntCreateWithInt64, JSBigIntCreateWithString, JSBigIntCreateWithUInt64, JSCheckScriptSyntax, JSClassRef, JSContextGroupRef, JSContextRef, JSEvaluateScript, JSGarbageCollect, JSGlobalContextRef, JSObjectGetArrayBufferByteLength, JSObjectGetArrayBufferBytesPtr, JSObjectGetTypedArrayBuffer, JSObjectGetTypedArrayByteLength, JSObjectGetTypedArrayByteOffset, JSObjectGetTypedArrayBytesPtr, JSObjectGetTypedArrayLength, JSObjectMakeArrayBufferWithBytesNoCopy, JSObjectMakeTypedArray, JSObjectMakeTypedArrayWithArrayBuffer, JSObjectMakeTypedArrayWithArrayBufferAndOffset, JSObjectMakeTypedArrayWithBytesNoCopy, JSObjectRef, JSPropertyNameAccumulatorRef, JSPropertyNameArrayRef, JSRelationCondition, JSStringRef, JSType, JSTypedArrayBytesDeallocator, JSTypedArrayType, JSValueCompare, JSValueCompareDouble, JSValueCompareInt64, JSValueCompareUInt64, JSValueCreateJSONString, JSValueGetType, JSValueGetTypedArrayType, JSValueIsArray, JSValueIsBigInt, JSValueIsBoolean, JSValueIsDate, JSValueIsEqual, JSValueIsInstanceOfConstructor, JSValueIsNull, JSValueIsNumber, JSValueIsObject, JSValueIsObjectOfClass, JSValueIsStrictEqual, JSValueIsString, JSValueIsSymbol, JSValueIsUndefined, JSValueMakeBoolean, JSValueMakeFromJSONString, JSValueMakeNull, JSValueMakeNumber, JSValueMakeString, JSValueMakeSymbol, JSValueMakeUndefined, JSValueProtect, JSValueRef, JSValueToBoolean, JSValueToInt32, JSValueToInt64, JSValueToNumber, JSValueToObject, JSValueToStringCopy, JSValueToUInt32, JSValueToUInt64, JSValueUnprotect, OpaqueJSClass, OpaqueJSContext, OpaqueJSContextGroup, OpaqueJSPropertyNameAccumulator, OpaqueJSPropertyNameArray, OpaqueJSString, OpaqueJSValue, jscHeader, $, JSBigIntCreateWithDouble, JSBigIntCreateWithInt64, JSBigIntCreateWithString, JSBigIntCreateWithUInt64, JSChar, JSCheckScriptSyntax, JSClassAttributes, JSClassCreate, JSClassDefinition, JSClassRef, JSClassRelease, JSClassRetain, JSContextGetGlobalContext, JSContextGetGlobalObject, JSContextGetGroup, JSContextGroupCreate, JSContextGroupRef, JSContextGroupRelease, JSContextGroupRetain, JSContextRef, JSEvaluateScript, JSGarbageCollect, JSGlobalContextCopyName, JSGlobalContextCreate, JSGlobalContextCreateInGroup, JSGlobalContextIsInspectable, JSGlobalContextRef, JSGlobalContextRelease, JSGlobalContextRetain, JSGlobalContextSetInspectable, JSGlobalContextSetName, JSObjectCallAsConstructor, JSObjectCallAsConstructorCallback, JSObjectCallAsFunction, JSObjectCallAsFunctionCallback, JSObjectConvertToTypeCallback, JSObjectCopyPropertyNames, JSObjectDeleteProperty, JSObjectDeletePropertyCallback, JSObjectDeletePropertyForKey, JSObjectFinalizeCallback, JSObjectGetPrivate, JSObjectGetProperty, JSObjectGetPropertyAtIndex, JSObjectGetPropertyCallback, JSObjectGetPropertyForKey, JSObjectGetPropertyNamesCallback, JSObjectGetPrototype, JSObjectHasInstanceCallback, JSObjectHasProperty, JSObjectHasPropertyCallback, JSObjectHasPropertyForKey, JSObjectInitializeCallback, JSObjectIsConstructor, JSObjectIsFunction, JSObjectMake, JSObjectMakeArray, JSObjectMakeConstructor, JSObjectMakeDate, JSObjectMakeDeferredPromise, JSObjectMakeError, JSObjectMakeFunction, JSObjectMakeFunctionWithCallback, JSObjectMakeRegExp, JSObjectRef, JSObjectSetPrivate, JSObjectSetProperty, JSObjectSetPropertyAtIndex, JSObjectSetPropertyCallback, JSObjectSetPropertyForKey, JSObjectSetPrototype, JSPropertyAttributes, JSPropertyNameAccumulatorAddName, JSPropertyNameAccumulatorRef, JSPropertyNameArrayGetCount, JSPropertyNameArrayGetNameAtIndex, JSPropertyNameArrayRef, JSPropertyNameArrayRelease, JSPropertyNameArrayRetain, JSRelationCondition, JSStaticFunction, JSStaticValue, JSStringCreateWithCharacters, JSStringCreateWithUTF8CString, JSStringGetCharactersPtr, JSStringGetLength, JSStringGetMaximumUTF8CStringSize, JSStringGetUTF8CString, JSStringIsEqual, JSStringIsEqualToUTF8CString, JSStringRef, JSStringRelease, JSStringRetain, JSType, JSTypedArrayBytesDeallocator, JSTypedArrayType, JSValueCompare, JSValueCompareDouble, JSValueCompareInt64, JSValueCompareUInt64, JSValueCreateJSONString, JSValueGetType, JSValueGetTypedArrayType, JSValueIsArray, JSValueIsBigInt, JSValueIsBoolean, JSValueIsDate, JSValueIsEqual, JSValueIsInstanceOfConstructor, JSValueIsNull, JSValueIsNumber, JSValueIsObject, JSValueIsObjectOfClass, JSValueIsStrictEqual, JSValueIsString, JSValueIsSymbol, JSValueIsUndefined, JSValueMakeBoolean, JSValueMakeFromJSONString, JSValueMakeNull, JSValueMakeNumber, JSValueMakeString, JSValueMakeSymbol, JSValueMakeUndefined, JSValueProtect, JSValueRef, JSValueToBoolean, JSValueToInt32, JSValueToInt64, JSValueToNumber, JSValueToObject, JSValueToStringCopy, JSValueToUInt32, JSValueToUInt64, JSValueUnprotect, OpaqueJSClass, OpaqueJSContext, OpaqueJSContextGroup, OpaqueJSPropertyNameAccumulator, OpaqueJSPropertyNameArray, OpaqueJSString, OpaqueJSValue, evalScript, jscHeader, kJSClassAttributeNoAutomaticPrototype, kJSClassAttributeNone, kJSClassDefinitionEmpty, kJSPropertyAttributeDontDelete, kJSPropertyAttributeDontEnum, kJSPropertyAttributeNone, kJSPropertyAttributeReadOnly, newJSString, withGlobalContext