mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-21 15:04:33 -05:00
feat: expose v8 version constants (#1569)
This commit is contained in:
parent
82301490d5
commit
68b96d1cae
4 changed files with 25 additions and 0 deletions
1
build.rs
1
build.rs
|
@ -152,6 +152,7 @@ fn build_binding() {
|
||||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
||||||
.clang_args(["-x", "c++", "-std=c++20", "-Iv8/include", "-I."])
|
.clang_args(["-x", "c++", "-std=c++20", "-Iv8/include", "-I."])
|
||||||
.clang_args(args)
|
.clang_args(args)
|
||||||
|
.generate_cstr(true)
|
||||||
.rustified_enum(".*UseCounterFeature")
|
.rustified_enum(".*UseCounterFeature")
|
||||||
.allowlist_item("v8__.*")
|
.allowlist_item("v8__.*")
|
||||||
.allowlist_item("cppgc__.*")
|
.allowlist_item("cppgc__.*")
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <v8-fast-api-calls.h>
|
#include <v8-fast-api-calls.h>
|
||||||
#include <v8-message.h>
|
#include <v8-message.h>
|
||||||
#include <v8-typed-array.h>
|
#include <v8-typed-array.h>
|
||||||
|
#include <v8-version-string.h>
|
||||||
|
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
|
||||||
|
@ -34,3 +35,9 @@ using v8__CFunction = v8::CFunction;
|
||||||
using v8__CFunctionInfo = v8::CFunctionInfo;
|
using v8__CFunctionInfo = v8::CFunctionInfo;
|
||||||
|
|
||||||
using v8__Isolate__UseCounterFeature = v8::Isolate::UseCounterFeature;
|
using v8__Isolate__UseCounterFeature = v8::Isolate::UseCounterFeature;
|
||||||
|
|
||||||
|
static uint32_t v8__MAJOR_VERSION = V8_MAJOR_VERSION;
|
||||||
|
static uint32_t v8__MINOR_VERSION = V8_MINOR_VERSION;
|
||||||
|
static uint32_t v8__BUILD_NUMBER = V8_BUILD_NUMBER;
|
||||||
|
static uint32_t v8__PATCH_LEVEL = V8_PATCH_LEVEL;
|
||||||
|
static const char* v8__VERSION_STRING = V8_VERSION_STRING;
|
||||||
|
|
16
src/lib.rs
16
src/lib.rs
|
@ -169,5 +169,21 @@ pub use value_serializer::ValueSerializerImpl;
|
||||||
pub use wasm::CompiledWasmModule;
|
pub use wasm::CompiledWasmModule;
|
||||||
pub use wasm::WasmStreaming;
|
pub use wasm::WasmStreaming;
|
||||||
|
|
||||||
|
/// https://v8.dev/docs/version-numbers
|
||||||
|
pub const MAJOR_VERSION: u32 = binding::v8__MAJOR_VERSION;
|
||||||
|
/// https://v8.dev/docs/version-numbers
|
||||||
|
pub const MINOR_VERSION: u32 = binding::v8__MINOR_VERSION;
|
||||||
|
/// https://v8.dev/docs/version-numbers
|
||||||
|
pub const BUILD_NUMBER: u32 = binding::v8__BUILD_NUMBER;
|
||||||
|
/// https://v8.dev/docs/version-numbers
|
||||||
|
pub const PATCH_LEVEL: u32 = binding::v8__PATCH_LEVEL;
|
||||||
|
/// https://v8.dev/docs/version-numbers
|
||||||
|
pub const VERSION_STRING: &str =
|
||||||
|
// TODO: cleanup when Result::unwrap is const stable.
|
||||||
|
match binding::v8__VERSION_STRING.to_str() {
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(_) => panic!("Unable to convert CStr to &str??"),
|
||||||
|
};
|
||||||
|
|
||||||
// TODO(piscisaureus): Ideally this trait would not be exported.
|
// TODO(piscisaureus): Ideally this trait would not be exported.
|
||||||
pub use support::MapFnTo;
|
pub use support::MapFnTo;
|
||||||
|
|
|
@ -1468,6 +1468,7 @@ fn script_origin() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn get_version() {
|
fn get_version() {
|
||||||
|
assert_eq!(v8::V8::get_version(), v8::VERSION_STRING);
|
||||||
assert!(v8::V8::get_version().len() > 3);
|
assert!(v8::V8::get_version().len() > 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue