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

feat: better error message printing when signature is missing #80

Merged
merged 1 commit into from
Jan 12, 2020
Merged
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
32 changes: 31 additions & 1 deletion crates/mun_abi/src/autogen_impl.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::prelude::*;

use std::ffi::{c_void, CStr};
use std::fmt::Formatter;
use std::marker::{Send, Sync};
use std::slice;
use std::str;
use std::{fmt, slice};

impl TypeInfo {
/// Returns the type's name.
Expand All @@ -12,6 +13,12 @@ impl TypeInfo {
}
}

impl fmt::Display for TypeInfo {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.name())
}
}

impl PartialEq for TypeInfo {
fn eq(&self, other: &Self) -> bool {
self.guid == other.guid
Expand Down Expand Up @@ -47,6 +54,23 @@ impl FunctionSignature {
}
}

impl fmt::Display for FunctionSignature {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "fn {}(", self.name())?;
for (i, arg) in self.arg_types().iter().enumerate() {
if i > 0 {
write!(f, ", ")?;
}
write!(f, "{}", arg)?;
}
write!(f, ")")?;
if let Some(ret_type) = self.return_type() {
write!(f, ":{}", ret_type)?
}
Ok(())
}
}

unsafe impl Send for FunctionSignature {}
unsafe impl Sync for FunctionSignature {}

Expand All @@ -71,6 +95,12 @@ impl StructInfo {
}
}

impl fmt::Display for StructInfo {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.name())
}
}

impl ModuleInfo {
/// Returns the module's full path.
pub fn path(&self) -> &str {
Expand Down