0
0
Fork 0
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:
Ry Dahl 2019-11-15 13:16:49 -05:00 committed by GitHub
parent c025a918c0
commit 3f6812ee60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -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(); }
}

View file

@ -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);
}