Renaming methods (#243)

This commit is contained in:
qwreey 2024-10-17 01:37:24 +00:00
parent ba074d9a28
commit 58add58244
No known key found for this signature in database
GPG key ID: D28DB79297A214BD
8 changed files with 25 additions and 25 deletions

View file

@ -152,15 +152,15 @@ impl LuaUserData for CArr {
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
// Subtype
method_provider::provide_ptr(methods);
method_provider::provide_ptr_info(methods);
// ToString
method_provider::provide_to_string(methods);
// Realize
method_provider::provide_box(methods);
method_provider::provide_from(methods);
method_provider::provide_into(methods);
method_provider::provide_from_data(methods);
method_provider::provide_into_data(methods);
methods.add_method("offset", |_, this, offset: isize| {
if this.length > (offset as usize) && offset >= 0 {

View file

@ -129,8 +129,8 @@ impl CFunc {
impl LuaUserData for CFunc {
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
// Subtype
method_provider::provide_ptr(methods);
method_provider::provide_arr(methods);
method_provider::provide_ptr_info(methods);
method_provider::provide_arr_info(methods);
// ToString
method_provider::provide_to_string(methods);

View file

@ -16,31 +16,31 @@ pub mod method_provider {
});
}
pub fn provide_ptr<'lua, Target, M>(methods: &mut M)
pub fn provide_ptr_info<'lua, Target, M>(methods: &mut M)
where
M: LuaUserDataMethods<'lua, Target>,
{
methods.add_function("ptr", |lua, this: LuaAnyUserData| {
methods.add_function("ptrInfo", |lua, this: LuaAnyUserData| {
CPtr::from_userdata(lua, &this)
});
}
pub fn provide_arr<'lua, Target, M>(methods: &mut M)
pub fn provide_arr_info<'lua, Target, M>(methods: &mut M)
where
M: LuaUserDataMethods<'lua, Target>,
{
methods.add_function("arr", |lua, (this, length): (LuaAnyUserData, usize)| {
methods.add_function("arrInfo", |lua, (this, length): (LuaAnyUserData, usize)| {
CArr::from_userdata(lua, &this, length)
});
}
pub fn provide_from<'lua, Target, M>(methods: &mut M)
pub fn provide_from_data<'lua, Target, M>(methods: &mut M)
where
Target: NativeSize + NativeConvert,
M: LuaUserDataMethods<'lua, Target>,
{
methods.add_method(
"from",
"fromData",
|lua, this, (userdata, offset): (LuaAnyUserData, Option<isize>)| {
let offset = offset.unwrap_or(0);
@ -57,13 +57,13 @@ pub mod method_provider {
);
}
pub fn provide_into<'lua, Target, M>(methods: &mut M)
pub fn provide_into_data<'lua, Target, M>(methods: &mut M)
where
Target: NativeSize + NativeConvert,
M: LuaUserDataMethods<'lua, Target>,
{
methods.add_method(
"into",
"intoData",
|lua, this, (userdata, value, offset): (LuaAnyUserData, LuaValue, Option<isize>)| {
let offset = offset.unwrap_or(0);

View file

@ -114,8 +114,8 @@ impl LuaUserData for CPtr {
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
// Subtype
method_provider::provide_ptr(methods);
method_provider::provide_arr(methods);
method_provider::provide_ptr_info(methods);
method_provider::provide_arr_info(methods);
// ToString
method_provider::provide_to_string(methods);

View file

@ -166,16 +166,16 @@ impl LuaUserData for CStruct {
}
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
// Subtype
method_provider::provide_ptr(methods);
method_provider::provide_arr(methods);
method_provider::provide_ptr_info(methods);
method_provider::provide_arr_info(methods);
// ToString
method_provider::provide_to_string(methods);
// Realize
method_provider::provide_box(methods);
method_provider::provide_from(methods);
method_provider::provide_into(methods);
method_provider::provide_from_data(methods);
method_provider::provide_into_data(methods);
methods.add_method("offset", |_, this, index: usize| {
let offset = this.offset(index)?;

View file

@ -98,16 +98,16 @@ where
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
// Subtype
method_provider::provide_ptr(methods);
method_provider::provide_arr(methods);
method_provider::provide_ptr_info(methods);
method_provider::provide_arr_info(methods);
// ToString
method_provider::provide_to_string(methods);
// Realize
method_provider::provide_box(methods);
method_provider::provide_from(methods);
method_provider::provide_into(methods);
method_provider::provide_from_data(methods);
method_provider::provide_into_data(methods);
methods.add_function(
"cast",

View file

@ -186,7 +186,7 @@ impl LuaUserData for FfiRef {
let ffiref = FfiRef::luaref(lua, this)?;
Ok(ffiref)
});
methods.add_method("isNullptr", |_, this, ()| Ok(this.is_nullptr()));
methods.add_method("isNull", |_, this, ()| Ok(this.is_nullptr()));
}
}

View file

@ -23,7 +23,7 @@ use crate::{
pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
let result = TableBuilder::new(lua)?
.with_values(export_ctypes(lua)?)?
.with_value("nullRef", create_nullptr(lua)?)?
.with_function("nullRef", |lua, ()| create_nullptr(lua))?
.with_function("box", |_lua, size: usize| Ok(FfiBox::new(size)))?
.with_function("open", |_lua, name: String| FfiLib::new(name))?
.with_function("structInfo", |lua, types: LuaTable| {