mirror of
https://github.com/lune-org/lune.git
synced 2025-04-18 10:53:46 +01:00
Renaming methods (#243)
This commit is contained in:
parent
ba074d9a28
commit
58add58244
8 changed files with 25 additions and 25 deletions
|
@ -152,15 +152,15 @@ impl LuaUserData for CArr {
|
||||||
|
|
||||||
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||||
// Subtype
|
// Subtype
|
||||||
method_provider::provide_ptr(methods);
|
method_provider::provide_ptr_info(methods);
|
||||||
|
|
||||||
// ToString
|
// ToString
|
||||||
method_provider::provide_to_string(methods);
|
method_provider::provide_to_string(methods);
|
||||||
|
|
||||||
// Realize
|
// Realize
|
||||||
method_provider::provide_box(methods);
|
method_provider::provide_box(methods);
|
||||||
method_provider::provide_from(methods);
|
method_provider::provide_from_data(methods);
|
||||||
method_provider::provide_into(methods);
|
method_provider::provide_into_data(methods);
|
||||||
|
|
||||||
methods.add_method("offset", |_, this, offset: isize| {
|
methods.add_method("offset", |_, this, offset: isize| {
|
||||||
if this.length > (offset as usize) && offset >= 0 {
|
if this.length > (offset as usize) && offset >= 0 {
|
||||||
|
|
|
@ -129,8 +129,8 @@ impl CFunc {
|
||||||
impl LuaUserData for CFunc {
|
impl LuaUserData for CFunc {
|
||||||
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||||
// Subtype
|
// Subtype
|
||||||
method_provider::provide_ptr(methods);
|
method_provider::provide_ptr_info(methods);
|
||||||
method_provider::provide_arr(methods);
|
method_provider::provide_arr_info(methods);
|
||||||
|
|
||||||
// ToString
|
// ToString
|
||||||
method_provider::provide_to_string(methods);
|
method_provider::provide_to_string(methods);
|
||||||
|
|
|
@ -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
|
where
|
||||||
M: LuaUserDataMethods<'lua, Target>,
|
M: LuaUserDataMethods<'lua, Target>,
|
||||||
{
|
{
|
||||||
methods.add_function("ptr", |lua, this: LuaAnyUserData| {
|
methods.add_function("ptrInfo", |lua, this: LuaAnyUserData| {
|
||||||
CPtr::from_userdata(lua, &this)
|
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
|
where
|
||||||
M: LuaUserDataMethods<'lua, Target>,
|
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)
|
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
|
where
|
||||||
Target: NativeSize + NativeConvert,
|
Target: NativeSize + NativeConvert,
|
||||||
M: LuaUserDataMethods<'lua, Target>,
|
M: LuaUserDataMethods<'lua, Target>,
|
||||||
{
|
{
|
||||||
methods.add_method(
|
methods.add_method(
|
||||||
"from",
|
"fromData",
|
||||||
|lua, this, (userdata, offset): (LuaAnyUserData, Option<isize>)| {
|
|lua, this, (userdata, offset): (LuaAnyUserData, Option<isize>)| {
|
||||||
let offset = offset.unwrap_or(0);
|
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
|
where
|
||||||
Target: NativeSize + NativeConvert,
|
Target: NativeSize + NativeConvert,
|
||||||
M: LuaUserDataMethods<'lua, Target>,
|
M: LuaUserDataMethods<'lua, Target>,
|
||||||
{
|
{
|
||||||
methods.add_method(
|
methods.add_method(
|
||||||
"into",
|
"intoData",
|
||||||
|lua, this, (userdata, value, offset): (LuaAnyUserData, LuaValue, Option<isize>)| {
|
|lua, this, (userdata, value, offset): (LuaAnyUserData, LuaValue, Option<isize>)| {
|
||||||
let offset = offset.unwrap_or(0);
|
let offset = offset.unwrap_or(0);
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,8 @@ impl LuaUserData for CPtr {
|
||||||
|
|
||||||
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||||
// Subtype
|
// Subtype
|
||||||
method_provider::provide_ptr(methods);
|
method_provider::provide_ptr_info(methods);
|
||||||
method_provider::provide_arr(methods);
|
method_provider::provide_arr_info(methods);
|
||||||
|
|
||||||
// ToString
|
// ToString
|
||||||
method_provider::provide_to_string(methods);
|
method_provider::provide_to_string(methods);
|
||||||
|
|
|
@ -166,16 +166,16 @@ impl LuaUserData for CStruct {
|
||||||
}
|
}
|
||||||
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||||
// Subtype
|
// Subtype
|
||||||
method_provider::provide_ptr(methods);
|
method_provider::provide_ptr_info(methods);
|
||||||
method_provider::provide_arr(methods);
|
method_provider::provide_arr_info(methods);
|
||||||
|
|
||||||
// ToString
|
// ToString
|
||||||
method_provider::provide_to_string(methods);
|
method_provider::provide_to_string(methods);
|
||||||
|
|
||||||
// Realize
|
// Realize
|
||||||
method_provider::provide_box(methods);
|
method_provider::provide_box(methods);
|
||||||
method_provider::provide_from(methods);
|
method_provider::provide_from_data(methods);
|
||||||
method_provider::provide_into(methods);
|
method_provider::provide_into_data(methods);
|
||||||
|
|
||||||
methods.add_method("offset", |_, this, index: usize| {
|
methods.add_method("offset", |_, this, index: usize| {
|
||||||
let offset = this.offset(index)?;
|
let offset = this.offset(index)?;
|
||||||
|
|
|
@ -98,16 +98,16 @@ where
|
||||||
|
|
||||||
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||||
// Subtype
|
// Subtype
|
||||||
method_provider::provide_ptr(methods);
|
method_provider::provide_ptr_info(methods);
|
||||||
method_provider::provide_arr(methods);
|
method_provider::provide_arr_info(methods);
|
||||||
|
|
||||||
// ToString
|
// ToString
|
||||||
method_provider::provide_to_string(methods);
|
method_provider::provide_to_string(methods);
|
||||||
|
|
||||||
// Realize
|
// Realize
|
||||||
method_provider::provide_box(methods);
|
method_provider::provide_box(methods);
|
||||||
method_provider::provide_from(methods);
|
method_provider::provide_from_data(methods);
|
||||||
method_provider::provide_into(methods);
|
method_provider::provide_into_data(methods);
|
||||||
|
|
||||||
methods.add_function(
|
methods.add_function(
|
||||||
"cast",
|
"cast",
|
||||||
|
|
|
@ -186,7 +186,7 @@ impl LuaUserData for FfiRef {
|
||||||
let ffiref = FfiRef::luaref(lua, this)?;
|
let ffiref = FfiRef::luaref(lua, this)?;
|
||||||
Ok(ffiref)
|
Ok(ffiref)
|
||||||
});
|
});
|
||||||
methods.add_method("isNullptr", |_, this, ()| Ok(this.is_nullptr()));
|
methods.add_method("isNull", |_, this, ()| Ok(this.is_nullptr()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::{
|
||||||
pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
|
pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
|
||||||
let result = TableBuilder::new(lua)?
|
let result = TableBuilder::new(lua)?
|
||||||
.with_values(export_ctypes(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("box", |_lua, size: usize| Ok(FfiBox::new(size)))?
|
||||||
.with_function("open", |_lua, name: String| FfiLib::new(name))?
|
.with_function("open", |_lua, name: String| FfiLib::new(name))?
|
||||||
.with_function("structInfo", |lua, types: LuaTable| {
|
.with_function("structInfo", |lua, types: LuaTable| {
|
||||||
|
|
Loading…
Add table
Reference in a new issue