Skip to content

Commit 83be2bc

Browse files
committed
Remove callable boundary check (#243)
1 parent b442ba7 commit 83be2bc

File tree

12 files changed

+61
-61
lines changed

12 files changed

+61
-61
lines changed

crates/lune-std-ffi/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ See [tests/ffi](../../tests/ffi/README.md)
1212

1313
- Add math operation.
1414

15-
> `CTypeInfo:add(target, from1, from2, ...)` and `:sub` `:mul` `:div` `:mod` `:pow`
15+
> Provide related methods: `CTypeInfo:add(target, from1, from2, ...)` and `:sub` `:mul` `:div` `:mod` `:pow` `:max` `:min` `:gt` `:lt`
1616
> Luau cannot handle f64, i64 or i128, so we should provide math operation for it
1717
1818
- Add bit operation

crates/lune-std-ffi/src/c/arr_info.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ impl FfiConvert for CArrInfo {
150150

151151
impl LuaUserData for CArrInfo {
152152
fn add_fields<'lua, F: LuaUserDataFields<'lua, Self>>(fields: &mut F) {
153-
fields.add_meta_field(LuaMetaMethod::Type, "CArr");
154153
fields.add_field_method_get("size", |_, this| Ok(this.get_size()));
155154
fields.add_field_method_get("length", |_, this| Ok(this.get_length()));
156155
fields.add_field_function_get("inner", |lua, this: LuaAnyUserData| {

crates/lune-std-ffi/src/c/fn_info.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,6 @@ impl CFnInfo {
203203
}
204204

205205
impl LuaUserData for CFnInfo {
206-
fn add_fields<'lua, F: LuaUserDataFields<'lua, Self>>(fields: &mut F) {
207-
fields.add_meta_field(LuaMetaMethod::Type, "CFn");
208-
}
209206
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
210207
// Subtype
211208
method_provider::provide_ptr(methods);

crates/lune-std-ffi/src/c/helper.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,17 @@ pub fn stringify(lua: &Lua, userdata: &LuaAnyUserData) -> LuaResult<String> {
314314
// get name tag for any c-type userdata
315315
pub fn get_tag_name(userdata: &LuaAnyUserData) -> LuaResult<String> {
316316
Ok(if userdata.is::<CStructInfo>() {
317-
String::from("CStruct")
317+
String::from("CStructInfo")
318318
} else if userdata.is::<CArrInfo>() {
319-
String::from("CArr")
319+
String::from("CArrInfo")
320320
} else if userdata.is::<CPtrInfo>() {
321-
String::from("CPtr")
321+
String::from("CPtrInfo")
322322
} else if userdata.is::<CFnInfo>() {
323-
String::from("CFn")
323+
String::from("CFnInfo")
324324
} else if userdata.is::<CVoidInfo>() {
325-
String::from("CVoid")
325+
String::from("CVoidInfo")
326326
} else if ctype_helper::is_ctype(userdata) {
327-
String::from("CType")
327+
String::from("CTypeInfo")
328328
} else {
329329
String::from("Unknown")
330330
})

crates/lune-std-ffi/src/c/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ mod arr_info;
55
mod fn_info;
66
pub mod helper;
77
mod ptr_info;
8+
mod string_info;
89
mod struct_info;
910
mod type_info;
1011
mod types;
@@ -15,6 +16,7 @@ pub use self::{
1516
fn_info::CFnInfo,
1617
helper::method_provider,
1718
ptr_info::CPtrInfo,
19+
string_info::CStringInfo,
1820
struct_info::CStructInfo,
1921
type_info::{CTypeCast, CTypeInfo},
2022
types::{ctype_helper, export_c_types, export_fixed_types},
@@ -44,5 +46,6 @@ pub fn export_c(lua: &Lua) -> LuaResult<LuaTable> {
4446
.with_function("fn", |lua, (args, ret): (LuaTable, LuaAnyUserData)| {
4547
CFnInfo::from_table(lua, args, ret)
4648
})?
49+
.with_value("string", CStringInfo::new())?
4750
.build_readonly()
4851
}

crates/lune-std-ffi/src/c/ptr_info.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ impl CPtrInfo {
124124

125125
impl LuaUserData for CPtrInfo {
126126
fn add_fields<'lua, F: LuaUserDataFields<'lua, Self>>(fields: &mut F) {
127-
fields.add_meta_field(LuaMetaMethod::Type, "CPtr");
128127
fields.add_field_method_get("size", |_, _| Ok(size_of::<usize>()));
129128
fields.add_field_function_get("inner", |lua, this| {
130129
let inner = association::get(lua, CPTR_INNER, this)?
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
use mlua::prelude::*;
12

3+
pub struct CStringInfo();
4+
5+
impl CStringInfo {
6+
pub fn new() -> Self {
7+
Self()
8+
}
9+
}
10+
11+
impl LuaUserData for CStringInfo {}

crates/lune-std-ffi/src/c/struct_info.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ impl FfiConvert for CStructInfo {
182182

183183
impl LuaUserData for CStructInfo {
184184
fn add_fields<'lua, F: LuaUserDataFields<'lua, Self>>(fields: &mut F) {
185-
fields.add_meta_field(LuaMetaMethod::Type, "CStruct");
186185
fields.add_field_method_get("size", |_, this| Ok(this.get_size()));
187186
}
188187
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {

crates/lune-std-ffi/src/c/type_info.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ where
9191
Self: CTypeCast + FfiSignedness + FfiConvert + FfiSize,
9292
{
9393
fn add_fields<'lua, F: LuaUserDataFields<'lua, Self>>(fields: &mut F) {
94-
fields.add_meta_field(LuaMetaMethod::Type, "CType");
94+
fields.add_meta_field(LuaMetaMethod::Type, "CTypeInfo");
9595
fields.add_field_method_get("size", |_, this| Ok(this.get_size()));
96-
fields.add_meta_field(LuaMetaMethod::Type, "CType");
9796
fields.add_field_method_get("signedness", |_, this| Ok(this.get_signedness()));
9897
}
9998

crates/lune-std-ffi/src/c/void_info.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ impl CVoidInfo {
3131
}
3232

3333
impl LuaUserData for CVoidInfo {
34-
fn add_fields<'lua, F: LuaUserDataFields<'lua, Self>>(fields: &mut F) {
35-
fields.add_meta_field(LuaMetaMethod::Type, "CVoid");
36-
}
3734
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
3835
method_provider::provide_to_string(methods);
3936
method_provider::provide_ptr(methods);

0 commit comments

Comments
 (0)