Skip to content

Commit

Permalink
fix not being able to compile properly both backends
Browse files Browse the repository at this point in the history
  • Loading branch information
lenscas committed Dec 15, 2023
1 parent 2a4971b commit da0736b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
8 changes: 6 additions & 2 deletions src/type_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ impl Deref for NameContainer {
#[cfg(feature = "rlua")]
impl<'lua> FromLuaR<'lua> for NameContainer {
fn from_lua(lua_value: rlua::Value<'lua>, lua: Context<'lua>) -> ResultR<Self> {
Ok(String::from_lua(lua_value, lua)?.into_bytes().into())
Ok(<String as FromLuaR>::from_lua(lua_value, lua)?
.into_bytes()
.into())
}
}
#[cfg(feature = "rlua")]
Expand All @@ -68,7 +70,9 @@ impl ToTypename for NameContainer {
#[cfg(feature = "mlua")]
impl<'lua> FromLuaM<'lua> for NameContainer {
fn from_lua(lua_value: mlua::Value<'lua>, lua: &'lua Lua) -> ResultM<Self> {
Ok(String::from_lua(lua_value, lua)?.into_bytes().into())
Ok(<String as FromLuaM>::from_lua(lua_value, lua)?
.into_bytes()
.into())
}
}
#[cfg(feature = "mlua")]
Expand Down
41 changes: 31 additions & 10 deletions src/type_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,26 @@ impl_type_name_life_time!("any" rlua::Value<'lua>);
impl_type_name_life_time!("any" mlua::Value<'lua>);

#[cfg(feature = "rlua")]
use rlua::{Table, Value};
use rlua::{Table as TableR, Value as ValueR};

#[cfg(feature = "mlua")]
use mlua::{Table, Value};
use mlua::{Table as TableM, Value as ValueM};

#[cfg(any(feature = "mlua", feature = "rlua"))]
impl<'lua> ToTypename for Table<'lua> {
#[cfg(feature = "rlua")]
impl<'lua> ToTypename for TableR<'lua> {
fn to_typename() -> Type {
Type::Map(crate::MapRepresentation {
key: ValueR::to_typename().into(),
value: ValueR::to_typename().into(),
})
}
}
#[cfg(feature = "mlua")]
impl<'lua> ToTypename for TableM<'lua> {
fn to_typename() -> Type {
Type::Map(crate::MapRepresentation {
key: Value::to_typename().into(),
value: Value::to_typename().into(),
key: ValueM::to_typename().into(),
value: ValueM::to_typename().into(),
})
}
}
Expand All @@ -308,12 +317,24 @@ impl_type_name_life_time!("string" rlua::String<'lua>);
impl_type_name_life_time!("string" mlua::String<'lua>);

#[cfg(feature = "mlua")]
use mlua::Function;
use mlua::Function as FunctionM;
#[cfg(feature = "rlua")]
use rlua::Function;
use rlua::Function as FunctionR;

#[cfg(any(feature = "mlua", feature = "rlua"))]
impl<'lua> ToTypename for Function<'lua> {
#[cfg(feature = "rlua")]
impl<'lua> ToTypename for FunctionR<'lua> {
fn to_typename() -> Type {
Type::Function(crate::FunctionRepresentation {
params: vec![FunctionParam {
param_name: Some("...".into()),
ty: Type::new_single("any", KindOfType::Builtin),
}],
returns: vec![Type::new_single("any...", KindOfType::Builtin)],
})
}
}
#[cfg(feature = "mlua")]
impl<'lua> ToTypename for FunctionM<'lua> {
fn to_typename() -> Type {
Type::Function(crate::FunctionRepresentation {
params: vec![FunctionParam {
Expand Down
2 changes: 1 addition & 1 deletion src/type_walker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl TypeWalker {
}
}

#[cfg(feature = "rlua")]
#[cfg(all(feature = "rlua", not(feature = "mlua")))]
impl TypeWalker {
///collect every instance that is getting shared with lua
pub fn document_global_instance<T: crate::rlu::ExportInstances>(
Expand Down

0 comments on commit da0736b

Please sign in to comment.