diff options
Diffstat (limited to 'src/zjs_util.h')
-rw-r--r-- | src/zjs_util.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/zjs_util.h b/src/zjs_util.h index 97feca2..734ccc1 100644 --- a/src/zjs_util.h +++ b/src/zjs_util.h @@ -463,4 +463,18 @@ void zjs_loop_init(void); ret; \ }) +#define ZJS_GET_HANDLE(obj, type, var, info) \ + type *var; \ + { \ + void *native; \ + const jerry_object_native_info_t *tmp; \ + if (!jerry_get_object_native_pointer(obj, &native, &tmp)) { \ + return zjs_error("no native handle"); \ + } \ + if (tmp != &info) { \ + return zjs_error("handle was incorrect type"); \ + } \ + var = (type *)native; \ + } + #endif // __zjs_util_h__ |