Rename LightUserData to LuaLightUserData for consistency
I know, this is the opposite of PR #17 wishes to do, please don't take this as an indication that I would wish to do the opposite. I actually want to discuss PR #17 with you, but I'm not sure about it yet, and my pedantry will not allow me to let this remain inconsistent in the meantime. This way, either way it's consistent haha.
This commit is contained in:
parent
160c5405e1
commit
6df96d8eb1
|
@ -148,13 +148,13 @@ impl<'lua> FromLua<'lua> for bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'lua> ToLua<'lua> for LightUserData {
|
impl<'lua> ToLua<'lua> for LuaLightUserData {
|
||||||
fn to_lua(self, _: &'lua Lua) -> LuaResult<LuaValue<'lua>> {
|
fn to_lua(self, _: &'lua Lua) -> LuaResult<LuaValue<'lua>> {
|
||||||
Ok(LuaValue::LightUserData(self))
|
Ok(LuaValue::LightUserData(self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'lua> FromLua<'lua> for LightUserData {
|
impl<'lua> FromLua<'lua> for LuaLightUserData {
|
||||||
fn from_lua(v: LuaValue, _: &'lua Lua) -> LuaResult<Self> {
|
fn from_lua(v: LuaValue, _: &'lua Lua) -> LuaResult<Self> {
|
||||||
match v {
|
match v {
|
||||||
LuaValue::LightUserData(ud) => Ok(ud),
|
LuaValue::LightUserData(ud) => Ok(ud),
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub enum LuaValue<'lua> {
|
||||||
/// The Lua value `true` or `false`.
|
/// The Lua value `true` or `false`.
|
||||||
Boolean(bool),
|
Boolean(bool),
|
||||||
/// A "light userdata" object, equivalent to a raw pointer.
|
/// A "light userdata" object, equivalent to a raw pointer.
|
||||||
LightUserData(LightUserData),
|
LightUserData(LuaLightUserData),
|
||||||
/// An integer number.
|
/// An integer number.
|
||||||
///
|
///
|
||||||
/// Any Lua number convertible to a `LuaInteger` will be represented as this variant.
|
/// Any Lua number convertible to a `LuaInteger` will be represented as this variant.
|
||||||
|
@ -164,7 +164,7 @@ pub type LuaNumber = ffi::lua_Number;
|
||||||
|
|
||||||
/// A "light" userdata value. Equivalent to an unmanaged raw pointer.
|
/// A "light" userdata value. Equivalent to an unmanaged raw pointer.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
pub struct LightUserData(pub *mut c_void);
|
pub struct LuaLightUserData(pub *mut c_void);
|
||||||
|
|
||||||
/// Handle to an internal Lua string.
|
/// Handle to an internal Lua string.
|
||||||
///
|
///
|
||||||
|
@ -1427,7 +1427,7 @@ impl Lua {
|
||||||
}
|
}
|
||||||
|
|
||||||
ffi::LUA_TLIGHTUSERDATA => {
|
ffi::LUA_TLIGHTUSERDATA => {
|
||||||
let ud = LuaValue::LightUserData(LightUserData(ffi::lua_touserdata(state, -1)));
|
let ud = LuaValue::LightUserData(LuaLightUserData(ffi::lua_touserdata(state, -1)));
|
||||||
ffi::lua_pop(state, 1);
|
ffi::lua_pop(state, 1);
|
||||||
ud
|
ud
|
||||||
}
|
}
|
||||||
|
|
|
@ -707,9 +707,9 @@ fn test_lightuserdata() {
|
||||||
let res = globals
|
let res = globals
|
||||||
.get::<_, LuaFunction>("id")
|
.get::<_, LuaFunction>("id")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.call::<_, LightUserData>(LightUserData(42 as *mut c_void))
|
.call::<_, LuaLightUserData>(LuaLightUserData(42 as *mut c_void))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(res, LightUserData(42 as *mut c_void));
|
assert_eq!(res, LuaLightUserData(42 as *mut c_void));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue