mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-25 15:29:43 -05:00
bind v8::V8::GetVersion (#9)
This commit is contained in:
parent
c025a918c0
commit
3f6812ee60
2 changed files with 15 additions and 0 deletions
|
@ -4,4 +4,6 @@ extern "C" {
|
|||
void v8__V8__SetFlagsFromCommandLine(int *argc, char **argv) {
|
||||
v8::V8::SetFlagsFromCommandLine(argc, argv, true);
|
||||
}
|
||||
|
||||
const char *v8__V8__GetVersion() { return v8::V8::GetVersion(); }
|
||||
}
|
||||
|
|
13
src/v8.rs
13
src/v8.rs
|
@ -11,6 +11,8 @@ extern "C" {
|
|||
argc: *mut c_int,
|
||||
argv: *mut *mut c_char,
|
||||
);
|
||||
|
||||
pub fn v8__V8__GetVersion() -> *const c_char;
|
||||
}
|
||||
|
||||
/// Pass the command line arguments to v8.
|
||||
|
@ -65,3 +67,14 @@ fn test_set_flags_from_command_line() {
|
|||
vec!["binaryname".to_string(), "--should-be-ignored".to_string()]
|
||||
);
|
||||
}
|
||||
|
||||
pub fn get_version() -> &'static str {
|
||||
let version = unsafe { v8__V8__GetVersion() };
|
||||
let c_str = unsafe { CStr::from_ptr(version) };
|
||||
c_str.to_str().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_version() {
|
||||
assert!(get_version().len() > 3);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue