0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2025-03-11 06:26:44 -04:00
rusty-v8/src/external_references.rs

26 lines
689 B
Rust
Raw Normal View History

2020-01-02 13:57:00 -05:00
// Copyright 2019-2020 the Deno authors. All rights reserved. MIT license.
use crate::function::FunctionCallback;
use crate::support::intptr_t;
use std::ffi::c_void;
pub struct ExternalReferences {
null_terminated: Vec<*const libc::c_void>,
}
unsafe impl Sync for ExternalReferences {}
impl ExternalReferences {
pub fn new(refs: &[FunctionCallback]) -> Self {
let mut null_terminated = Vec::with_capacity(refs.len() + 1);
for r in refs {
null_terminated.push(*r as *const c_void);
}
null_terminated.push(std::ptr::null());
Self { null_terminated }
}
pub fn as_ptr(&self) -> *const intptr_t {
self.null_terminated.as_ptr() as *const intptr_t
}
}