Skip to content

Commit

Permalink
added functions to get id of proxy instance
Browse files Browse the repository at this point in the history
  • Loading branch information
andrieshiemstra committed Jan 3, 2024
1 parent 09d3be3 commit 199b24f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.11.6

* added get_proxy_instance_id for getting instance id without looking up the proxy
* console functions output source filename

# 0.11.5

* more robust stacktrace parser, again
Expand Down
24 changes: 24 additions & 0 deletions src/reflection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,30 @@ pub fn get_proxy_instance_proxy_and_instance_id_q(
}
}

pub fn get_proxy_instance_id_q(
q_ctx: &QuickJsRealmAdapter,
obj: &QuickJsValueAdapter,
) -> Option<usize> {
if !is_proxy_instance_q(q_ctx, obj) {
None
} else {
let info = get_proxy_instance_info(obj.borrow_value());
Some(info.id)
}
}

pub unsafe fn get_proxy_instance_id(
ctx: *mut libquickjs_sys::JSContext,
obj: &QuickJsValueAdapter,
) -> Option<usize> {
if !is_proxy_instance(ctx, obj) {
None
} else {
let info = get_proxy_instance_info(obj.borrow_value());
Some(info.id)
}
}

pub fn is_proxy_instance_q(q_ctx: &QuickJsRealmAdapter, obj: &QuickJsValueAdapter) -> bool {
unsafe { is_proxy_instance(q_ctx.context, obj) }
}
Expand Down

0 comments on commit 199b24f

Please sign in to comment.