MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1#ifndef ANT_PTR_H
2#define ANT_PTR_H
3
4#include "types.h"
5#include "internal.h" // IWYU pragma: keep
6
7static inline void js_set_native_ptr(ant_value_t obj, void *ptr) {
8 ant_object_t *o = js_obj_ptr(obj);
9 if (!o) return;
10 o->native.ptr = ptr;
11}
12
13static inline void *js_get_native_ptr(ant_value_t obj) {
14 ant_object_t *o = js_obj_ptr(obj);
15 return o ? o->native.ptr : NULL;
16}
17
18static inline void js_set_native_tag(ant_value_t obj, uint32_t tag) {
19 ant_object_t *o = js_obj_ptr(obj);
20 if (!o) return;
21 o->native.tag = tag;
22}
23
24static inline uint32_t js_get_native_tag(ant_value_t obj) {
25 ant_object_t *o = js_obj_ptr(obj);
26 return o ? o->native.tag : 0;
27}
28
29
30static inline bool js_check_native_tag(ant_value_t obj, uint32_t tag) {
31 return js_get_native_tag(obj) == tag;
32}
33
34#endif