Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix not being able to compile properly both backends #84

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading