DelSkayn / rquickjs

High level bindings to the quickjs javascript engine
MIT License
504 stars 63 forks source link

Class and callback rework #176

Closed DelSkayn closed 1 year ago

DelSkayn commented 1 year ago

This PR aims to rework the class and callback system as well as their associated macros. Specifically the Class and Function objects, ClassDef and AsFunction traits and the bind macro.

Motivation

The current class and callback system was designed around a few functions which proved to be unsound (see #167 and #83). To remedy this unsoundness these functions had to be removed. This however lead to one no longer being able to access class data mutably or by reference the internal rust class for the duration of a Javascript object. This in turn made these systems a lot harder to work with and caused a lot of boilerplate when implementing functions and classes in rust for Javascript.

This PR completely redesigns the class system, and aims to remove the restrictions put on by the removed functions as well as remove a bunch of restrictions which where in place even before the unsound functions where removed.

Changes

The following is a non-exhaustive overview of all the changes this PR makes.