lightpanda-io / zig-js-runtime

Add a JS runtime in your Zig project
https://lightpanda.io
Apache License 2.0
16 stars 0 forks source link

Add NativeContext and remove global variables from utils #162

Closed francisbouvier closed 10 months ago

francisbouvier commented 10 months ago

As specified by v8 API we can provide an additional data argument when creating Function callbacks ; this data can then be retrieved when the callback is invoked. see https://v8.github.io/api/head/classv8_1_1FunctionCallbackInfo.html#ab0ebfc2ea43af2fdfc3d085272bf499f

We use this to pass a native context pointer with relevant elements (memory allocator, I/O loop) and remove the former ugly global variable access.

Relates to #49 and #66