Skip to content

Commit 09e1b13

Browse files
committed
Refactor This to Object.
1 parent 13e514d commit 09e1b13

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

examples/hello/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use phper::{
44
functions::Argument,
55
ini::Policy,
66
modules::{Module, ModuleArgs},
7-
objects::This,
7+
objects::Object,
88
php_get_module,
99
values::{SetVal, Val},
1010
};
@@ -65,15 +65,15 @@ pub fn get_module(module: &mut Module) {
6565
foo_class.add_property("foo", 100);
6666
foo_class.add_method(
6767
"getFoo",
68-
|this: &mut This, _: &mut [Val]| {
68+
|this: &mut Object, _: &mut [Val]| {
6969
let prop = this.get_property("foo");
7070
Val::from_val(prop)
7171
},
7272
vec![],
7373
);
7474
foo_class.add_method(
7575
"setFoo",
76-
|this: &mut This, arguments: &mut [Val]| {
76+
|this: &mut Object, arguments: &mut [Val]| {
7777
let prop = this.get_property("foo");
7878
prop.set(&arguments[0]);
7979
},

phper/src/functions.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77

88
use crate::{
99
classes::ClassEntry,
10-
objects::This,
10+
objects::Object,
1111
sys::*,
1212
values::{ExecuteData, SetVal, Val},
1313
};
@@ -28,15 +28,15 @@ where
2828
}
2929

3030
pub trait Method: Send + Sync {
31-
fn call(&self, this: &mut This, arguments: &mut [Val], return_value: &mut Val);
31+
fn call(&self, this: &mut Object, arguments: &mut [Val], return_value: &mut Val);
3232
}
3333

3434
impl<F, R> Method for F
3535
where
36-
F: Fn(&mut This, &mut [Val]) -> R + Send + Sync,
36+
F: Fn(&mut Object, &mut [Val]) -> R + Send + Sync,
3737
R: SetVal,
3838
{
39-
fn call(&self, this: &mut This, arguments: &mut [Val], return_value: &mut Val) {
39+
fn call(&self, this: &mut Object, arguments: &mut [Val], return_value: &mut Val) {
4040
let r = self(this, arguments);
4141
r.set_val(return_value);
4242
}
@@ -189,7 +189,7 @@ pub(crate) unsafe extern "C" fn invoke(
189189
f.call(&mut arguments, return_value);
190190
}
191191
Callable::Method(m, class) => {
192-
let mut this = This::new(execute_data.get_this(), class.load(Ordering::SeqCst));
192+
let mut this = Object::new(execute_data.get_this(), class.load(Ordering::SeqCst));
193193
m.call(&mut this, &mut arguments, return_value);
194194
}
195195
}

phper/src/objects.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::{classes::ClassEntry, sys::*, values::Val};
22
use std::ptr::null_mut;
33

4-
pub struct This {
4+
pub struct Object {
55
val: *mut Val,
66
class: *mut ClassEntry,
77
}
88

9-
impl This {
10-
pub(crate) fn new<'a>(val: *mut Val, class: *mut ClassEntry) -> This {
9+
impl Object {
10+
pub(crate) fn new<'a>(val: *mut Val, class: *mut ClassEntry) -> Object {
1111
assert!(!val.is_null());
1212
assert!(!class.is_null());
1313
Self { val, class }

0 commit comments

Comments
 (0)