Skip to content
Open
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
35 changes: 10 additions & 25 deletions src/codegen/sys/lib_.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
fs,
io::{Error, Result, Write},

Check warning on line 3 in src/codegen/sys/lib_.rs

View workflow job for this annotation

GitHub Actions / build-deploy

unused import: `Error`

Check failure on line 3 in src/codegen/sys/lib_.rs

View workflow job for this annotation

GitHub Actions / Hygiene (ubuntu-latest, stable)

unused import: `Error`

Check warning on line 3 in src/codegen/sys/lib_.rs

View workflow job for this annotation

GitHub Actions / Build/Test (ubuntu-latest, nightly)

unused import: `Error`

Check warning on line 3 in src/codegen/sys/lib_.rs

View workflow job for this annotation

GitHub Actions / Build/Test (ubuntu-latest, nightly)

unused import: `Error`

Check warning on line 3 in src/codegen/sys/lib_.rs

View workflow job for this annotation

GitHub Actions / Build/Test (ubuntu-latest, stable)

unused import: `Error`

Check warning on line 3 in src/codegen/sys/lib_.rs

View workflow job for this annotation

GitHub Actions / Build/Test (ubuntu-latest, stable)

unused import: `Error`
};

use log::info;
Expand Down Expand Up @@ -62,31 +62,16 @@
generate_classes_structs(w, env, &classes)?;
generate_interfaces_structs(w, env, &interfaces)?;

if env.namespaces.main().shared_libs.is_empty()
&& !(records.iter().all(|x| x.functions.is_empty())
&& classes.iter().all(|x| x.functions.is_empty())
&& interfaces.iter().all(|x| x.functions.is_empty())
&& bitfields.iter().all(|x| x.functions.is_empty())
&& enums.iter().all(|x| x.functions.is_empty())
&& unions.iter().all(|x| x.functions.is_empty()))
{
return Err(Error::other(
"No shared library found, but functions were found",
));
}

if !env.namespaces.main().shared_libs.is_empty() {
writeln!(w, "unsafe extern \"C\" {{")?;
functions::generate_enums_funcs(w, env, &enums)?;
functions::generate_bitfields_funcs(w, env, &bitfields)?;
functions::generate_unions_funcs(w, env, &unions)?;
functions::generate_records_funcs(w, env, &records)?;
functions::generate_classes_funcs(w, env, &classes)?;
functions::generate_interfaces_funcs(w, env, &interfaces)?;
functions::generate_other_funcs(w, env, &ns.functions)?;

writeln!(w, "\n}}")?;
}
writeln!(w, "unsafe extern \"C\" {{")?;
functions::generate_enums_funcs(w, env, &enums)?;
functions::generate_bitfields_funcs(w, env, &bitfields)?;
functions::generate_unions_funcs(w, env, &unions)?;
functions::generate_records_funcs(w, env, &records)?;
functions::generate_classes_funcs(w, env, &classes)?;
functions::generate_interfaces_funcs(w, env, &interfaces)?;
functions::generate_other_funcs(w, env, &ns.functions)?;

writeln!(w, "\n}}")?;

Ok(())
}
Expand Down
Loading