Statics.hx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. class Statics {
  2. static var BASE_PATH = "../../";
  3. static function loopRec( dir : String ) {
  4. for( f in sys.FileSystem.readDirectory(BASE_PATH+dir) ) {
  5. var path = dir + "/" + f;
  6. if( sys.FileSystem.isDirectory(BASE_PATH+path) ) {
  7. loopRec(path);
  8. continue;
  9. }
  10. var ext = f.split(".").pop().toLowerCase();
  11. if( ext != "c" && ext != "cpp" ) continue;
  12. var lineNum = 0;
  13. for( l in sys.io.File.getContent(BASE_PATH+path).split("\n") ) {
  14. lineNum++;
  15. var l = StringTools.rtrim(l);
  16. if( l == "" ) continue;
  17. switch( l.charCodeAt(0) ) {
  18. case '\t'.code, '*'.code, '#'.code, '}'.code:
  19. continue;
  20. default:
  21. if( !StringTools.endsWith(l,";") )
  22. continue;
  23. // function decl
  24. if( StringTools.endsWith(l,");") )
  25. continue;
  26. if( l.indexOf(" const ") > 0 )
  27. continue;
  28. for( w in ["HL_PRIM ","HL_API ","DEFINE_PRIM","typedef","struct","//","/*"," *"," "] )
  29. if( StringTools.startsWith(l,w) ) {
  30. l = null;
  31. break;
  32. }
  33. if( l == null )
  34. continue;
  35. Sys.println('$path:$lineNum: $l');
  36. }
  37. }
  38. }
  39. }
  40. static function main() {
  41. for( dir in ["src","libs"] )
  42. loopRec(dir);
  43. }
  44. }