mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-03-09 13:38:51 -04:00
Add ReturnValue::set_bool
(#1020)
This commit is contained in:
parent
61714dd2b2
commit
e6b443a6e8
3 changed files with 32 additions and 4 deletions
|
@ -1846,6 +1846,10 @@ void v8__ReturnValue__Set(v8::ReturnValue<v8::Value>* self,
|
||||||
self->Set(ptr_to_local(&value));
|
self->Set(ptr_to_local(&value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void v8__ReturnValue__Set__Bool(v8::ReturnValue<v8::Value>* self, bool i) {
|
||||||
|
self->Set(i);
|
||||||
|
}
|
||||||
|
|
||||||
void v8__ReturnValue__Set__Int32(v8::ReturnValue<v8::Value>* self, int32_t i) {
|
void v8__ReturnValue__Set__Int32(v8::ReturnValue<v8::Value>* self, int32_t i) {
|
||||||
self->Set(i);
|
self->Set(i);
|
||||||
}
|
}
|
||||||
|
@ -1859,10 +1863,6 @@ void v8__ReturnValue__Set__Double(v8::ReturnValue<v8::Value>* self, double i) {
|
||||||
self->Set(i);
|
self->Set(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void v8__ReturnValue__Set__Bool(v8::ReturnValue<v8::Value>* self, bool value) {
|
|
||||||
self->Set(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void v8__ReturnValue__SetNull(v8::ReturnValue<v8::Value>* self) {
|
void v8__ReturnValue__SetNull(v8::ReturnValue<v8::Value>* self) {
|
||||||
self->SetNull();
|
self->SetNull();
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ extern "C" {
|
||||||
) -> *const Object;
|
) -> *const Object;
|
||||||
|
|
||||||
fn v8__ReturnValue__Set(this: *mut ReturnValue, value: *const Value);
|
fn v8__ReturnValue__Set(this: *mut ReturnValue, value: *const Value);
|
||||||
|
fn v8__ReturnValue__Set__Bool(this: *mut ReturnValue, value: bool);
|
||||||
fn v8__ReturnValue__Set__Int32(this: *mut ReturnValue, value: i32);
|
fn v8__ReturnValue__Set__Int32(this: *mut ReturnValue, value: i32);
|
||||||
fn v8__ReturnValue__Set__Uint32(this: *mut ReturnValue, value: u32);
|
fn v8__ReturnValue__Set__Uint32(this: *mut ReturnValue, value: u32);
|
||||||
fn v8__ReturnValue__Set__Double(this: *mut ReturnValue, value: f64);
|
fn v8__ReturnValue__Set__Double(this: *mut ReturnValue, value: f64);
|
||||||
|
@ -148,6 +149,10 @@ impl<'cb> ReturnValue<'cb> {
|
||||||
unsafe { v8__ReturnValue__Set(&mut *self, &*value) }
|
unsafe { v8__ReturnValue__Set(&mut *self, &*value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_bool(&mut self, value: bool) {
|
||||||
|
unsafe { v8__ReturnValue__Set__Bool(&mut *self, value) }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_int32(&mut self, value: i32) {
|
pub fn set_int32(&mut self, value: i32) {
|
||||||
unsafe { v8__ReturnValue__Set__Int32(&mut *self, value) }
|
unsafe { v8__ReturnValue__Set__Int32(&mut *self, value) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -2324,6 +2324,29 @@ fn return_value() {
|
||||||
let global = context.global(scope);
|
let global = context.global(scope);
|
||||||
let recv: v8::Local<v8::Value> = global.into();
|
let recv: v8::Local<v8::Value> = global.into();
|
||||||
|
|
||||||
|
// set_bool
|
||||||
|
{
|
||||||
|
let template = v8::FunctionTemplate::new(
|
||||||
|
scope,
|
||||||
|
|scope: &mut v8::HandleScope,
|
||||||
|
args: v8::FunctionCallbackArguments,
|
||||||
|
mut rv: v8::ReturnValue| {
|
||||||
|
assert_eq!(args.length(), 0);
|
||||||
|
assert!(rv.get(scope).is_undefined());
|
||||||
|
rv.set_bool(false);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
let function = template
|
||||||
|
.get_function(scope)
|
||||||
|
.expect("Unable to create function");
|
||||||
|
let value = function
|
||||||
|
.call(scope, recv, &[])
|
||||||
|
.expect("Function call failed");
|
||||||
|
assert!(value.is_boolean());
|
||||||
|
assert!(!value.is_true());
|
||||||
|
}
|
||||||
|
|
||||||
// set_int32
|
// set_int32
|
||||||
{
|
{
|
||||||
let template = v8::FunctionTemplate::new(
|
let template = v8::FunctionTemplate::new(
|
||||||
|
|
Loading…
Add table
Reference in a new issue