tables.sbn 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. {{~
  2. func get_table_inner_name
  3. ret '_' + ($0 | string.downcase)
  4. end
  5. ~}}
  6. {{~for table in __tables ~}}
  7. {{declaring_import_table table '/gen/'}}
  8. {{~end~}}
  9. final class {{__name}}
  10. {
  11. final Future<dynamic> Function(String filePath) _asyncloadFunction;
  12. Tables(this._asyncloadFunction);
  13. {{~for table in __tables ~}}
  14. {{~if table.comment != '' ~}}
  15. //{{escape_comment table.comment}}
  16. {{~end~}}
  17. {{table.name}}? _{{format_property_name __code_style table.name}};
  18. {{~end~}}
  19. Future<void> waitLoad() async {
  20. var results = await Future.wait([
  21. {{~for table in __tables ~}}
  22. _asyncloadFunction("{{table.output_data_file}}"),
  23. {{~end~}}
  24. ]);
  25. {{ idx=0 }}
  26. {{~for table in __tables ~}}
  27. _{{format_property_name __code_style table.name}} = {{table.name}}(results[{{idx}}]);{{idx=idx+1}}
  28. {{~end~}}
  29. resolveRef();
  30. }
  31. {{~for table in __tables ~}}
  32. {{table.name}}? get {{format_name_lower_camel table.name}} => _{{format_property_name __code_style table.name}};
  33. {{~end~}}
  34. void resolveRef(){
  35. {{~for table in __tables ~}}
  36. _{{format_property_name __code_style table.name}}?.resolveRef(this);
  37. {{~end~}}
  38. }
  39. }