Skip to content

Commit

Permalink
Update headers for 1.2.0-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjs committed Oct 29, 2020
1 parent c0a444b commit 7f9de24
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 26 deletions.
135 changes: 119 additions & 16 deletions JavaScriptCore/JSObjectRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ derived class (the parent class) first, and the most derived class last.
typedef void
(*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object);

/* Extension of the above callback with the class that the method is being invoked for. */
typedef void
(*JSObjectInitializeCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object);

/*!
@typedef JSObjectFinalizeCallback
@abstract The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.
Expand All @@ -109,6 +113,10 @@ all functions that have a JSContextRef parameter.
typedef void
(*JSObjectFinalizeCallback) (JSObjectRef object);

/* Extension of the above callback with the class that the method is being invoked for. */
typedef void
(*JSObjectFinalizeCallbackEx) (JSClassRef jsClass, JSObjectRef object);

/*!
@typedef JSObjectHasPropertyCallback
@abstract The callback invoked when determining whether an object has a property.
Expand All @@ -129,6 +137,10 @@ If this callback is NULL, the getProperty callback will be used to service hasPr
typedef bool
(*JSObjectHasPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);

/* Extension of the above callback with the class that the method is being invoked for. */
typedef bool
(*JSObjectHasPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName);

/*!
@typedef JSObjectGetPropertyCallback
@abstract The callback invoked when getting a property's value.
Expand All @@ -146,6 +158,10 @@ If this function returns NULL, the get request forwards to object's statically d
typedef JSValueRef
(*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);

/* Extension of the above callback with the class that the method is being invoked for. */
typedef JSValueRef
(*JSObjectGetPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);

/*!
@typedef JSObjectSetPropertyCallback
@abstract The callback invoked when setting a property's value.
Expand All @@ -164,6 +180,10 @@ If this function returns false, the set request forwards to object's statically
typedef bool
(*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);

/* Extension of the above callback with the class that the method is being invoked for. */
typedef bool
(*JSObjectSetPropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);

/*!
@typedef JSObjectDeletePropertyCallback
@abstract The callback invoked when deleting a property.
Expand All @@ -181,6 +201,10 @@ If this function returns false, the delete request forwards to object's statical
typedef bool
(*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);

/* Extension of the above callback with the class that the method is being invoked for. */
typedef bool
(*JSObjectDeletePropertyCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);

/*!
@typedef JSObjectGetPropertyNamesCallback
@abstract The callback invoked when collecting the names of an object's properties.
Expand All @@ -198,6 +222,10 @@ Use JSPropertyNameAccumulatorAddName to add property names to accumulator. A cla
typedef void
(*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);

/* Extension of the above callback with the class that the method is being invoked for. */
typedef void
(*JSObjectGetPropertyNamesCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);

/*!
@typedef JSObjectCallAsFunctionCallback
@abstract The callback invoked when an object is called as a function.
Expand All @@ -219,6 +247,12 @@ If this callback is NULL, calling your object as a function will throw an except
typedef JSValueRef
(*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);

/* Extension of the above callback with the class and class name of the object being called as a function.
@discussion If this is a JSStaticFunctionEx, className will actually be the name of the function.
*/
typedef JSValueRef
(*JSObjectCallAsFunctionCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSStringRef className, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);

/*!
@typedef JSObjectCallAsConstructorCallback
@abstract The callback invoked when an object is used as a constructor in a 'new' expression.
Expand All @@ -239,6 +273,10 @@ If this callback is NULL, using your object as a constructor in a 'new' expressi
typedef JSObjectRef
(*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);

/* Extension of the above callback with the class that the method is being invoked for. */
typedef JSObjectRef
(*JSObjectCallAsConstructorCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);

/*!
@typedef JSObjectHasInstanceCallback
@abstract hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
Expand All @@ -260,6 +298,10 @@ Standard JavaScript practice calls for objects that implement the callAsConstruc
typedef bool
(*JSObjectHasInstanceCallback) (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);

/* Extension of the above callback with the class that the method is being invoked for. */
typedef bool
(*JSObjectHasInstanceCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);

/*!
@typedef JSObjectConvertToTypeCallback
@abstract The callback invoked when converting an object to a particular JavaScript type.
Expand All @@ -279,6 +321,10 @@ This function is only invoked when converting an object to number or string. An
typedef JSValueRef
(*JSObjectConvertToTypeCallback) (JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);

/* Extension of the above callback with the class that the method is being invoked for. */
typedef JSValueRef
(*JSObjectConvertToTypeCallbackEx) (JSContextRef ctx, JSClassRef jsClass, JSObjectRef object, JSType type, JSValueRef* exception);

/*!
@struct JSStaticValue
@abstract This structure describes a statically declared value property.
Expand All @@ -294,6 +340,14 @@ typedef struct {
JSPropertyAttributes attributes;
} JSStaticValue;

/* Extension of the above structure for use with class version 1000 */
typedef struct {
const char* name;
JSObjectGetPropertyCallbackEx getPropertyEx;
JSObjectSetPropertyCallbackEx setPropertyEx;
JSPropertyAttributes attributes;
} JSStaticValueEx;

/*!
@struct JSStaticFunction
@abstract This structure describes a statically declared function property.
Expand All @@ -307,6 +361,13 @@ typedef struct {
JSPropertyAttributes attributes;
} JSStaticFunction;

/* Extension of the above structure for use with class version 1000 */
typedef struct {
const char* name;
JSObjectCallAsFunctionCallbackEx callAsFunctionEx;
JSPropertyAttributes attributes;
} JSStaticFunctionEx;

/*!
@struct JSClassDefinition
@abstract This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL.
Expand Down Expand Up @@ -341,26 +402,49 @@ Standard JavaScript practice calls for storing function objects in prototypes, s
A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute.
*/
typedef struct {
int version; /* current (and only) version is 0 */
int version; /* default version is 0, use version 1000 for callbacks with extended class information */
JSClassAttributes attributes;

const char* className;
JSClassRef parentClass;

const JSStaticValue* staticValues;
const JSStaticFunction* staticFunctions;

JSObjectInitializeCallback initialize;
JSObjectFinalizeCallback finalize;
JSObjectHasPropertyCallback hasProperty;
JSObjectGetPropertyCallback getProperty;
JSObjectSetPropertyCallback setProperty;
JSObjectDeletePropertyCallback deleteProperty;
JSObjectGetPropertyNamesCallback getPropertyNames;
JSObjectCallAsFunctionCallback callAsFunction;
JSObjectCallAsConstructorCallback callAsConstructor;
JSObjectHasInstanceCallback hasInstance;
JSObjectConvertToTypeCallback convertToType;

union {
/* version 0 */
struct {
const JSStaticValue* staticValues;
const JSStaticFunction* staticFunctions;
JSObjectInitializeCallback initialize;
JSObjectFinalizeCallback finalize;
JSObjectHasPropertyCallback hasProperty;
JSObjectGetPropertyCallback getProperty;
JSObjectSetPropertyCallback setProperty;
JSObjectDeletePropertyCallback deleteProperty;
JSObjectGetPropertyNamesCallback getPropertyNames;
JSObjectCallAsFunctionCallback callAsFunction;
JSObjectCallAsConstructorCallback callAsConstructor;
JSObjectHasInstanceCallback hasInstance;
JSObjectConvertToTypeCallback convertToType;
};

/* version 1000 */
struct {
const JSStaticValueEx* staticValuesEx;
const JSStaticFunctionEx* staticFunctionsEx;
JSObjectInitializeCallbackEx initializeEx;
JSObjectFinalizeCallbackEx finalizeEx;
JSObjectHasPropertyCallbackEx hasPropertyEx;
JSObjectGetPropertyCallbackEx getPropertyEx;
JSObjectSetPropertyCallbackEx setPropertyEx;
JSObjectDeletePropertyCallbackEx deletePropertyEx;
JSObjectGetPropertyNamesCallbackEx getPropertyNamesEx;
JSObjectCallAsFunctionCallbackEx callAsFunctionEx;
JSObjectCallAsConstructorCallbackEx callAsConstructorEx;
JSObjectHasInstanceCallbackEx hasInstanceEx;
JSObjectConvertToTypeCallbackEx convertToTypeEx;
};
};

void* privateData; /* version 1000 only */
} JSClassDefinition;

/*!
Expand Down Expand Up @@ -396,6 +480,25 @@ JS_EXPORT JSClassRef JSClassRetain(JSClassRef jsClass);
*/
JS_EXPORT void JSClassRelease(JSClassRef jsClass);

/*!
@function
@abstract Retrieves the private data from a class reference, only possible with classes created with version 1000 (extended callbacks).
@param jsClass The class to get the data from
@result The private data on the class, or NULL, if not set
@discussion Only classes with version 1000 (extended callbacks) can store private data, for other classes always NULL will always be returned.
*/
JS_EXPORT void* JSClassGetPrivate(JSClassRef jsClass);

/*!
@function
@abstract Sets the private data on a class, only possible with classes created with version 1000 (extended callbacks).
@param jsClass The class to set the data on
@param data A void* to set as the private data for the class
@result true if the data has been set on the class, false if the class has not been created with version 1000 (extended callbacks)
@discussion Only classes with version 1000 (extended callbacks) can store private data, for other classes the function always fails. The set pointer is not touched by the engine.
*/
JS_EXPORT bool JSClassSetPrivate(JSClassRef jsClass, void* data);

/*!
@function
@abstract Creates a JavaScript object.
Expand Down
7 changes: 6 additions & 1 deletion Ultralight/Bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,18 @@ class UExport Bitmap : public RefCounted {
virtual uint32_t bpp() const = 0;

///
/// Get the number of bytes between each row (this is always >= width * bpp)
/// Get the number of bytes between each row of pixels.
///
/// @note This value is usually calculated as width * bytes_per_pixel (bpp)
/// but it may be larger due to alignment rules in the allocator.
///
virtual uint32_t row_bytes() const = 0;

///
/// Get the size in bytes of the pixel buffer.
///
/// @note Size is calculated as row_bytes() * height().
///
virtual size_t size() const = 0;

///
Expand Down
24 changes: 17 additions & 7 deletions Ultralight/CAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ ULExport ULString ulSessionGetDiskPath(ULSession session);
///
ULExport ULView ulCreateView(ULRenderer renderer, unsigned int width,
unsigned int height, bool transparent,
ULSession session);
ULSession session, bool force_cpu_renderer);

///
/// Destroy a View.
Expand Down Expand Up @@ -654,12 +654,22 @@ ULExport void ulViewUnlockJSContext(ULView view);
///
/// @param js_string The string of JavaScript to evaluate.
///
/// @param exception A string to store the exception in, if any. Pass NULL
/// if you don't care about exceptions.
///
/// @note Don't destroy the returned string, it is owned by the View. This
/// value is reset with every call-- if you want to retain it you should
/// copy the result to a new string via ulCreateStringFromCopy().
/// @param exception The address of a ULString to store a description of the
/// last exception. Pass NULL to ignore this. Don't destroy
/// the exception string returned, it's owned by the View.
///
/// @note Don't destroy the returned string, it's owned by the View. This value
/// is reset with every call-- if you want to retain it you should copy
/// the result to a new string via ulCreateStringFromCopy().
///
/// @note An example of using this API:
/// <pre>
/// ULString script = ulCreateString("1 + 1");
/// ULString exception;
/// ULString result = ulViewEvaluateScript(view, script, &exception);
/// /* Use the result ("2") and exception description (if any) here. */
/// ulDestroyString(script);
/// </pre>
///
ULExport ULString ulViewEvaluateScript(ULView view, ULString js_string, ULString* exception);

Expand Down
2 changes: 1 addition & 1 deletion Ultralight/KeyEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class UExport KeyEvent {
/// This is a string identifying the key that was pressed. This can be
/// generated from the virtual_key_code via the GetKeyIdentifierFromVirtualKeyCode()
/// utility function. You can find the full list of key identifiers at:
/// <http://www.w3.org/TR/DOM-Level-3-Events/keyset.html>
/// <https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/keyset.html>

This comment has been minimized.

Copy link
@SupinePandora43

SupinePandora43 Oct 30, 2020

s - security

///
String key_identifier;

Expand Down
3 changes: 2 additions & 1 deletion Ultralight/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class UExport Renderer : public RefCounted {
/// (nullable).
///
virtual Ref<View> CreateView(uint32_t width, uint32_t height,
bool transparent, RefPtr<Session> session) = 0;
bool transparent, RefPtr<Session> session,
bool force_cpu_renderer = false) = 0;

///
/// Update timers and dispatch internal callbacks. You should call this often
Expand Down

0 comments on commit 7f9de24

Please sign in to comment.