(
&mut self,
resolve: &Resolve,
world_id: WorldId,
funcs: &[(&str, &Function)],
_files: &mut Files,
)
| 305 | } |
| 306 | |
| 307 | fn export_funcs( |
| 308 | &mut self, |
| 309 | resolve: &Resolve, |
| 310 | world_id: WorldId, |
| 311 | funcs: &[(&str, &Function)], |
| 312 | _files: &mut Files, |
| 313 | ) -> anyhow::Result<()> { |
| 314 | let name = &format!("{}-world", resolve.worlds[world_id].name).to_upper_camel_case(); |
| 315 | let name = &format!("{name}.I{name}Exports"); |
| 316 | let mut r#gen = self.interface(resolve, name, Direction::Export, true); |
| 317 | |
| 318 | // Write the export types used by the functions. |
| 319 | let world = &resolve.worlds[world_id]; |
| 320 | let mut types = Vec::new(); |
| 321 | for (name, export) in world.exports.iter() { |
| 322 | match name { |
| 323 | WorldKey::Name(name) => match export { |
| 324 | WorldItem::Type { id, .. } => { |
| 325 | if !CSharp::type_is_bidirectional(resolve, &id) { |
| 326 | types.push((name.as_str(), *id)) |
| 327 | } |
| 328 | } |
| 329 | _ => {} |
| 330 | }, |
| 331 | WorldKey::Interface(_) => {} |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | if !types.is_empty() { |
| 336 | export_types(&mut r#gen, &types); |
| 337 | } |
| 338 | |
| 339 | for (resource, funcs) in by_resource( |
| 340 | funcs.iter().copied(), |
| 341 | r#gen.csharp_gen.world_resources.keys().copied(), |
| 342 | ) { |
| 343 | if let Some(resource) = resource { |
| 344 | r#gen.start_resource(resource, None); |
| 345 | } |
| 346 | |
| 347 | for func in funcs { |
| 348 | r#gen.export(func, None); |
| 349 | } |
| 350 | |
| 351 | if resource.is_some() { |
| 352 | r#gen.end_resource(); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | r#gen.add_world_fragment(Some(Direction::Export)); |
| 357 | Ok(()) |
| 358 | } |
| 359 | |
| 360 | fn import_types( |
| 361 | &mut self, |
nothing calls this directly
no test coverage detected