Commit a0068c61 authored by Ryan Hunt's avatar Ryan Hunt
Browse files

Be sure to treat &str as UTF8

parent 82793732
const FOO: i32 = 10;
const BAR: &'static libc::c_char = "hello world";
const BAR: &'static str = "hello world";
const ZOM: f32 = 3.14;
#[repr(C)]
struct Foo {
......
......@@ -19,7 +19,7 @@ impl LiteralExpr {
pub fn load(expr: &syn::Expr) -> Result<LiteralExpr, String> {
match &expr.node {
&syn::ExprKind::Lit(syn::Lit::Str(ref text, ..)) => {
Ok(LiteralExpr(format!("\"{}\"", text)))
Ok(LiteralExpr(format!("u8\"{}\"", text)))
}
&syn::ExprKind::Lit(syn::Lit::Byte(value)) => {
Ok(LiteralExpr(format!("{}", value)))
......
......@@ -45,6 +45,7 @@ pub enum PrimitiveType {
Float,
Double,
SizeT,
Str,
}
impl PrimitiveType {
......@@ -79,6 +80,7 @@ impl PrimitiveType {
"f32" => Some(PrimitiveType::Float),
"f64" => Some(PrimitiveType::Double),
"size_t" => Some(PrimitiveType::SizeT),
"str" => Some(PrimitiveType::Str),
_ => None,
}
}
......@@ -112,6 +114,7 @@ impl PrimitiveType {
&PrimitiveType::Float => "f32",
&PrimitiveType::Double => "f64",
&PrimitiveType::SizeT => "size_t",
&PrimitiveType::Str => "str",
}
}
......@@ -144,6 +147,7 @@ impl PrimitiveType {
&PrimitiveType::Float => "float",
&PrimitiveType::Double => "double",
&PrimitiveType::SizeT => "size_t",
&PrimitiveType::Str => "char",
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment